Skip to content

Simplified Scoreboard Expressions

antD97 edited this page May 18, 2022 · 8 revisions

Expressions that start with #!sb can be used for a more concise way of doing arithmetic through scoreboard player ... commands.

scoreboard player <set,add,remove> <targets> <objective> <score>

To set, add, or remove a value from a player's score, use the format: #!sb <targets> <objective> <=,+=,-=> <score>

Regex: (?:\s|^)#!sb (\S+) (\S+) (=|\+=|-=) (-?\d+)(?:\s|$)

This:

#!sb @a objective_name = -77
#!sb @s[type=creeper,scores={objective_name=111}] objective_name += 222
#!sb global objective_name -= 489

Turns into this:

scoreboard players set @a objective_name -77
scoreboard players add @s[type=creeper,scores={objective_name=111}] objective_name 222
scoreboard players remove global objective_name 489

scoreboard players operation <targets> <targetObjective> <operation> <source> <sourceObjective>

To execute an operation using two player's scores, use the format: #!sb <targets> <targetObjective> <operation> <source> <sourceObjective>

Regex: (?:\s|^)#!sb (\S+) (\S+) (\+=|-=|\*=|\/=|%=|=|<|>|><) (\S+) (\S+)(?:\s|$)

This:

#!sb @a objective_name += @p some_other_objective
#!sb @s[type=creeper,scores={objective_name=111}] objective_name = global some_other_objective
#!sb global objective_name *= @s some_other_objective

Turns into this:

scoreboard players set @a objective_name += @p some_other_objective
scoreboard players add @s[type=creeper,scores={objective_name=111}] objective_name = global some_other_objective
scoreboard players remove global objective_name *= @s some_other_objective

scoreboard players reset <targets> [<objective>]

To reset a player's score back to its default value, use the format: #!sb reset <targets> [<objective>]

Regex: (?:\s|^)#!sb reset (\S+)( \S+)?(?:\s|$)

This:

#!sb reset @a objective_name
#!sb reset @e[type=creeper,scores={objective_name=-111}]

Turns into this:

scoreboard players reset @a objective_name
scoreboard players reset @e[type=creeper,scores={objective_name=-111}]

scoreboard players enable <targets> <objective>

To enable a player's trigger score, use the format: #!sb enable <targets> <objective>

Regex: (?:\s|^)#!sb enable (\S+) (\S+)(?:\s|$)

This:

#!sb enable @a objective_name

Turns into this:

scoreboard players enable @a objective_name