set num:5
will define a variable named num and store the value 5 for later use.check: checks some condition and then does one thing if it's true or another thing if it's not true.
locateSelf
check (dir > 180)
yes:fire
no:right
The above block of code will do the following:
do: Do starts a loop of commands. It's useful with check.
check (something = someotherthing)
yes: do (fire fire fire fire)
no: do (left move)
The above code will check some condition, and if it's true the robots next four actions will be to fire. If not, the robot will turn left and move.
Some condition and some other condition will return true only if both conditions are true.
Some condition or some other condition will return true if either of them are true.
locateEnemy
check (edir > 170 and edir < 190)
yes: move
no: idle
is the same as...
locateEnemy
check (edir > 170)
yes: check (edir < 190)
yes: move
no: idle
no: idle
Both of the above snippets will load in the enemy's location and direction and then fire only if the enemy is pointing almost straight up. The execution is the same, but code with ands or ors is much more readable than nested check statements.
The basic operations are available + - * / for addition, subtraction, multiplication and division. You can also use % for modulous (getting the remainder of a division answer). For example 10 % 3 will return 1 since one is the remainder of 10 / 3.
The order of operations is the same as in arithmetic (multiplication before addition, etc...) and you can use parenthesis to change the order.
1 + 2 * 4 == 9
However...(1 + 2) * 4 == 12