M HYPE SPLASH
// news

Using Mathematical Operations in /testfor command in Minecraft

By Emily Wilson

Say I have the objective test which is stat.killEntity.Zombie. I also have another objective test2 which is also a stat.entityKilledBy.Zombie. Can I make a new objective, which is a dummy, and the value of that is test + test2. Is this possible? If not, what is the best alternative?

1 Answer

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 their test1 score, and then add onto that their test2 score.

This is only sets their test3 score once (it won't automatically always be test + test2 now), so you'll need to do this on a clock or just before you /testfor a certain test3 score.

1