Is there any way to use scoreboard objectives as arguments for commands?
For example, say I have a command block that should teleport a player to a location based on their score.
tp Notch score_Notch_Deaths 0 0This should teleport Notch to an x-coordinate based on his Deaths score.
If this is possible, what would the actual syntax be?
12 Answers
There is no way to directly use an objective as a command argument. Dinnerbone has said that the reason for this is that he wanted to avoid making commands into a full programming language.
The best you can do is something like this:
tp @a[score_Notch_Deaths_min=1,score_Notch_Deaths=1] 1 0 0
tp @a[score_Notch_Deaths_min=2,score_Notch_Deaths=2] 2 0 0
tp @a[score_Notch_Deaths_min=3,score_Notch_Deaths=3] 3 0 0In separate command blocks, and then activate them all at once. It would be tedious to do by hand, so I'd suggest using an MCEdit filter such as Texelelf's command block filter to fill out the incrementing values automatically.
1You need to do it recursively.
do this: /tp Notch 0 0 0
then you need these on a fill clock
/tp @a[name=Notch,score_Deaths_min=1] ~1 ~ ~
/scoreboard players remove Notch Deaths 1 1