-
Notifications
You must be signed in to change notification settings - Fork 5
Tutorial 1.2. Command block modifiers
In the first tutorial we learned how to compile and import an application into Minecraft, but we had to manually adjust a few things because we didn't use any MPL-specific syntax. Now we will cover command block modifiers that specify whether an impulse, chain or repeat command block will be generated and whether or not it is conditional or needs redstone. For information on command block modifiers in Minecraft visit the Minecraft Wiki.
Every command can have 3 modifiers in the following order:
- mode: can be impulse, chain or repeat
- conditional: can be unconditional, conditional or invert
- redstone: can be needs redstone or always active
With this we can now adjust our counter of the first tutorial, so we don't have to manually set the first command to be repeating:
repeat: /scoreboard players add @a COUNTER 1
/scoreboard players set @a[score_COUNTER_min=10] COUNTER 1
Here is another example that will print "sandstone" whenever a player steps on sandstone. Otherwise it will print "not sandstone":
repeat, always active: /execute @a ~ ~ ~ /testforblock ~ ~-1 ~ sandstone
conditional: /say sandstone
invert: /say not sandstone
Note that:
- The default mode value is chain
- The default conditional value is unconditional
- The default redstone value is always active for chain commands and needs redstone for impulse and repeat
The invert modifier works exactly like a conditional command, but in reverse. It will only activate when the previous command did not succeed. Because the /say command is always successful when it is executed, the invert of the last example depends on the /execute ... /testfor
command.
Our counter from the first tutorial is still not complete. In Tutorial 1.3. Installation we will learn how to automatically create the scoreboards for our program.