Operators

Arithmetic, comparison, and logic. The language has no infix operators — every operator is an ordinary command call, written prefix and normally bracketed so its result becomes an argument:

[+ 1 2]                       # 3
[ge [level $actor] 10]        # true if the actor is level 10+

Arithmetic — int → int

Call Result
[+ a b] sum
[- a b] difference
[* a b] product
[/ a b] integer quotient
[% a b] remainder (modulo)

Both operands must be int; a non-int operand is a run-time type error. Dividing or taking the remainder by zero is a run-time error.

after command (say) {
  do "say there are [- [level $actor] 1] levels below you"
}

Against a level-26 actor this says "there are 25 levels below you."

Comparison → bool

Call True when
[eq a b] the two values are equal
[ne a b] they are not equal
[gt a b] a > b
[lt a b] a < b
[ge a b] a >= b
[le a b] a <= b

eq / ne work on any comparable values and follow the equality rules in Values — e.g. [eq '1' 1] is false (string vs int). The ordered comparisons gt lt ge le require int operands. For case-insensitive string comparison use streqi, not eq.

after command (say) {
  if [ge [level $actor] 10] {
    do "say welcome, veteran"
  } else {
    do "say you have much to learn"
  }
}

Logic → bool

Call Result
[not a] logical negation
[and a b …] true when every operand is true
[or a b …] true when any operand is true

All operands must be bool. and and or take two or more operands. There is no truthiness coercion — passing a non-bool (a string, an int, or null) raises a type error (see Values — boolean contexts).

after command (say) {
  if [and [ge [level $actor] 10] [lt [level $actor] 100]] {
    do "say you are mid-tier"
  }
}

For an inverted condition, wrap the test: if [not [isplayer $actor]] { … }.

See also