0

Is there a way to create a Minecraft scoreboard object that counts all kinds of stone?

Like:

/scoreboard objectives add stonecounter stats.useItem.1
/scoreboard objectives add stonebrickcounter stats.useItem.X
/scoreboard objectives add cobblestonecounter stats.useItem.XX

and then sum all the objectives to one allstonecounter and display that number on the sideboard?

Something like:

/scoreboard objectives setdisplay sideboard (stonecounter+stonebrickcounter+cobblestonecounter)

1 Answer 1

3

You can use scoreboard operations to add one score to another.

/scoreboard players operation <affected_target> <affected_objective> <operation> <target> <objective>

Operations available: +=, -=, *=, /=, %=, <, >, ><, =

More information concerning scoreboards can be found here.

Prerequisites:

You will need another objective to hold the value:

/scoreboard objectives add stonetotal dummy

Clock commands:

The following must be run in numerical order on a clock.

  1. Reset all player's "stonetotal" score to 0. Without this, their score will constantly increase.

     /scoreboard players set @a[score_stonetotal_min=1] stonetotal 0
    
  2. Cause all players to run the /scoreboard command, targeting their own scores. They will increment their "stonetotal" score equal to their respective stone scores.

     /execute @a ~ ~ ~ /scoreboard players operation @a[c=1] stonetotal += @a[c=1] stonecounter
     /execute @a ~ ~ ~ /scoreboard players operation @a[c=1] stonetotal += @a[c=1] stonebrickcounter
     /execute @a ~ ~ ~ /scoreboard players operation @a[c=1] stonetotal += @a[c=1] cobblestonecounter
    
7
  • I don't think you need to execute the scoreboard operation, you can use @a stonetotal += * ... (if memory serves). Also, if you are going to execute the operation, why not use @p in the scoreboard portion?
    – MBraedley
    Jan 2, 2016 at 1:33
  • @MBraedley IIRC, @p doesn't select dead players, whereas @a[c=1] can.
    – SirBenet
    Jan 2, 2016 at 1:49
  • But, IIRC, @a (without the argument) doesn't select dead players either. Or maybe I'm just thinking about a specific use of /tp.
    – MBraedley
    Jan 2, 2016 at 1:50
  • @MBraedley If you don't use /execute, then you will be unable to change specific playerscores based on their own score. You'd instead either be changing a single player's score based on the collective scores, or changing all playerscores based on a single target's score. Using /execute is to split the senders up so they can increment their own scores based on their own scores. @a is the only target selector that can target dead players, so mixing @a with @p is not recommended.
    – Skylinerw
    Jan 2, 2016 at 1:54
  • 1
    @MBraedley You can join multiple players onto a LAN world with just one account, or test with fake scoreboard players.
    – SirBenet
    Jan 2, 2016 at 2:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .