Repository navigation
Expressions
Two places take an expression rather than a number: setting a timer's length, and asking whether a condition holds.
/timer expr create round 60 * players_online
/timer expr set round 300
/timer expr add round 30
The expression is worked out when the command runs, and the result is the
number of seconds. It is not re-evaluated afterwards — a timer created with
60 * players_online on an empty server is a very short timer.
Arithmetic is + - * / % with brackets, and the result is rounded to a whole
number of seconds.
/timer trigger event add expression finish players_online > 4
/timer trigger event add expression start time_remaining < 30 && players_online > 0
This one is re-evaluated, every tick, while the trigger is being watched. See Triggers for when that is.
| Comparisons |
< <= > >= == !=
|
| Logic |
&& || !
|
| Grouping | ( ) |
| Arithmetic |
+ - * / %
|
time_remaining |
seconds left on the execution |
time_elapsed |
seconds gone |
players_online |
how many players are on the server |
score(objective, holder) |
a scoreboard score |
ftb_quest_completed(id) |
whether that FTB quest is done |
ftb_reward_claimed(id) |
whether that FTB reward is claimed |
time_remaining and time_elapsed read the execution the condition is being
checked for, so a timer running fifty times gets fifty different answers.
time_remaining < 60
players_online >= 2 && players_online <= 8
score(kills, Bob) > 10
time_elapsed > 300 || score(ready, @a) == 1
!ftb_quest_completed(12345)
(time_remaining < 30 && players_online > 0) || score(force_end, server) == 1
An expression that cannot be read is refused when you type it, with the reason. One that reads a value that does not exist — a missing objective, a holder with no score — treats it as zero rather than failing.
For a plain "when this score reaches this number", the scoreboard trigger kind
says it more directly and does not need an expression:
/timer trigger event add scoreboard kills 10 finish
Reach for an expression when you need more than one thing at once, or arithmetic between them.