#Math with commands

1 messages · Page 1 of 1 (latest)

vapid scarab
#

There are 2 players, each selects a number between 1-10, the player with the higher number gets as many points at the difference between the 2 selected numbers are.

I have some idea how to go about this, but Im not 100% sure. I think I start by having a scoreboard for each player, setting it to the number they selected. Then I use the "if score" command to compare them... From here on, im kinda lost. How exactly should I find the difference between them and keep track of the total points?

ripe pierBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1748195065:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

proper trellis
#

keeping track of the total points is just again using a scoreboard

vapid scarab
#

Oh yea right, I´ll just set up a separate scoreboard. Any idea how to actually get the difference and import it into the scoreboard for points?

grizzled lion
#

You can use the if score command to see if A > B, and if it is, use a scoreboard operation to subtract B from A, which will store the result (aka the difference) to A, which you can then add to A_Total. If A !> B, then you know B is greater, and you can subtract B from A to store the result to B, and then add that to B_Total.

And if the scores are equal then you don't need to check for that because both players' scores stay the same

vapid scarab
#

Awesome! Tysm 🙂