How do I use Gamerule variables in commands?
I'm attempting to get my head around the minecraft "Gamerule global variables" (e.g. custom game rules which you can use to store a value) but there seems to be very little useful info about them available.
For instance: /gamerule TestVar 10 creates a new variable.
I would like to be able to use this in another command, such as a fill command, e.g. something along the lines of:
/fill ~ ~1 ~ ~ ~[TestVar] ~ minecraft:stone 0 keep
(This command would create a stone tower on top of the command block with a height equal to the TestVar. In the case above, it would be 10 high)
Is there any way to use a variable like this inside a command?
Update: I am open to using scoreboards, objectives, stats or anything else in vanilla minecraft. I'd just like to be able to insert a variable value into a static command.
Pictures about "How do I use Gamerule variables in commands?"



How do you use the Gamerule command in Minecraft?
When in-game, game rules can be changed using the /gamerule command, using the syntax /gamerule <rule> [<value>] , where <rule> is the name of the game rule and <value> is an allowed value, which depends on the type of the game rule.How do you use variables in Minecraft?
/gamerule doDaylightCycle added, which turns the daylight cycle on or off.What does Gamerule doDaylightCycle do?
If you want to activate and re-enable Spread Fire in Minecraft, simply enter /gamerule doFireTick true. Doing so will allow you to re-activate the Fire Spreading command. Now, you can go around setting fires again.Minecraft 1.16 - All Gamerules
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Brett Jordan, Ivan Samkov, Andrea Piacquadio, Andrea Piacquadio
