TransWikia.com

Is there any way to create a variable in minecraft?

Arqade Asked on August 29, 2021

I know that there is no direct way to create a variable in Minecraft but is there any way to manipulate scoreboard objectives into creating one?

Basically, I need to create a variable that will store a players X Y Z when they reach less than 10 health.
The name of the “Health” objective is “down”.

I’m not sure how to make this question less like a demand. I’m not sure where to start on this but the main thing that I am “Capable” of is looking online for other questions. The only thing that has come up are people asking for this to be added, but someone in a forum mentioned scoreboard objectives being able to do the trick.

EDIT

So I don’t beleive I was clear enough: I need this to store the players location data live. As in a repeating command block test’s for a player with less than ten health and then stores the players current location which I can then use later to teleport the player to the saved coordinates. E.g

/testfor @a[score_down=10] {Coordinated:[{X(var X) = 1,Y(var Y) = 2,Z(var Z) = 3}]}

Basicall y ^ that works like Coordinated < Position Tag, X < X position tag, var < declared that the output will be the variable.

THAT IS IMPOSSIBLE ^

But I hope you catch my drift by the way I explain it.

3 Answers

I realised that there was an alternative way to do what I needed to do and this did not involve creating a variable. The reason I wanted to know the player's location live was so I could freeze them on the spot. Instead, I used this:

/execute @a[score_down=10] ~ ~ ~ /summon ArmorStand ~ ~ ~ {Invisible:1b,Invulnerable:1b,NoBasePlate:1b,NoGravity:1b,Small:1b}

/tp @a[score_down=10] @e[type=ArmorStand]

You can, of course, give the ArmorStand a custom name to reduce glitchiness but I did not need it.

Correct answer by Reflexive on August 29, 2021

today I was searching how to make a variables and I found, that closest thing to variables is a /scoreboard objectives add score dummy "score"

edit: score is a name of the variable

Answered by kudy on August 29, 2021

/scoreboard objectives add score dummy "score"  

/gamerule commandBlockOutput false 

/execute at [your name] if block ~ ~-1 ~ grass_block run scoreboard players set [your name] score 1

/execute at [your name] if score [your name] score matches 1 run setblock ~ ~-1 ~ minecraft:quartz_block replace  

/execute at [your name] run scoreboard players reset [your name] score

Answered by kudy on August 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP