Pass Command Into FOR Loop and Read Current Value of i
Is there a way I can call
splib:forwith a command that takes a numeric value, and have the command read fromiIn my specific example, I want to pass a function that applies to every slot of the inventory.stop = 36The command applying to every inventory slot takes aslotvalue (in this case, the value ofi), andcmd, which is a command to apply to each slot.
splib:for# Create objective scoreboard objectives add splib dummy # Call recursive helper $function splib:for_loop { stop: $(stop), cmd: "$(cmd)" } # Remove objective scoreboard objectives remove splib
splib:for_loop# if $i in $range # run command $execute if score i splib matches ..$(stop) run $(cmd) # $i++ scoreboard players add i splib 1 # if $i in $range # run $self $execute if score i splib matches ..$(stop) run function splib:for_loop { stop: $(stop), cmd: "$(cmd)" }