Minecraft scoreboard scores as command arguments

minecraft-commandsminecraft-java-edition

Say I have a scoreboard named var, is there a way to use this score as an argument in a command, for instance:

\tp playername ~ playername.var ~

Which should teleport the player with the name playernameto the y coordinate equal to their var score?

Edit: My question is is this possible, not what mods support this or is this a suggestion for a new feature.

Best Answer

No, this is not possible (well, easily)

Minecraft sadly does not support insertion of scoreboard scores anywhere in a command, they can only be used in selectors (e.g. @a[score_myScore_=1]) or in the /scoreboard players test command.

However, there are a few (albeit complicated) workarounds. They work by running a bunch of conditional teleportation commands using distances decrementing in binary.

This command block modules fits your example, although I believe it uses the 1.8 command blocks. It shouldn't be too hard to adapt though, the mechanism is fairly intuitive.

However, that only fits your specific case. There is no general solution. 90% of the time you'll be able to do some binary version for that specific situation though, and if you ever make a good one, please let the community know :D