Skip to content

Expressions

An expression is a calculation or a condition: %a + 1, ( 2 + 2 ) * 3, #Hits < 50, %a = 1 && %b = 2. It is built from values, variables, operators and parentheses.

set %var 1337 ; a value
set %temp %var ; a variable
set %next %var + 1 ; an operator
set %calc ( 2 + 2 ) * ( 3 - 1 ) ; parentheses: 8
set %flag ! #true ; an operator before a value: 0
display ok %next %calc %flag
halt

Only five commands work out expressions: set, if, while, until and return. Every other command takes its parameters as they are: wait %a + 1 waits %a ticks and ignores the rest. To pass a calculated value to another command, calculate it with set first:

set %a 19
set %delay %a + 1
wait %delay ; 20 ticks: one second
halt

A line is split into words at spaces, and every operator and parenthesis has to be a word of its own:

set %b 1
set %a %b + 1 ; right: 2
set %c %b+1 ; wrong: "%b+1" is one word, so nothing is added
display ok %a %c
if ( %a > 1 ) ; right
display ok %a is bigger than 1
if (%a > 1) ; wrong: "(%a" and "1)" are not understood
display ok never shown
halt

Calculations use whole numbers only. A value that is not a number counts as 0 in arithmetic. See Operators for every operator and the order they are worked out in.

A script is a list of lines. Each line holds one command and its parameters, and runs from the first word to the end of the line or to a ;, which starts a comment.

  • A long line can continue on the next lines: start each continuation with +. The pieces are joined without a space, so write + more text (with a space after +) where you want one.
  • A block is a group of lines between a { line and a } line. Blocks belong to if, else, for, while, sub and a few others. The braces go on lines of their own, and the { has to be the line right after the command it belongs to.
set %a 3
if %a > 2
{
set %b %a * 2
display ok %b
}
display ok This is a long message that
+ goes on over two lines.
halt

Based on the EasyUO wiki, edited for EasyUO Reforged. This text is available under the GNU Free Documentation License 1.2.