Using Mathematical Operations in /testfor command in Minecraft
-
Say I have the objective
test
which isstat.killEntity.Zombie
. I also have another objectivetest2
which is also astat.entityKilledBy.Zombie
. Can I make a new objective, which is adummy
, and the value of that istest + test2
. Is this possible? If not, what is the best alternative?
-
The
/scoreboard
command allows you to perform operations with player's scores.To make it so that
test3 = test + test2
for all online players, do something like this:execute @a ~ ~ ~ scoreboard players operation @p test3 = @p test execute @a ~ ~ ~ scoreboard players operation @p test3 += @p test2
That makes everyone set their
test3
score to theirtest1
score, and then add onto that theirtest2
score.This is only sets their
test3
score once (it won't automatically always betest + test2
now), so you'll need to do this on a clock or just before you/testfor
a certaintest3
score.