26.9. Expressions

Expressions can be used in the Expression Controller, the Property Sensor and the Property Actuator.

Table 26-1. Valid expressions

Expression type Example
Integer numbers 15
Float number 12.23224
Booleans TRUE, FALSE
Strings "I am a string!"
Properties propname
Sensornames sensorname (as named in the LogicBrick)


Table 26-2. Arithmetic expressions

Expression Example
EXPR1 + EXPR2 Addition, 12+3, propname+21
EXPR1 - EXPR2 Subtraction, 12-3, propname-21
EXPR1 * EXPR2 Multiplication, 12*3, propname*21
EXPR1 / EXPR2 Division, 12/3, propname/21
EXPR1 > EXPR2 EXPR1 greater EXPR2
EXPR1 >= EXPR2 EXPR1 greater or equal EXPR2
EXPR1 < EXPR2 EXPR1 less EXPR2


Table 26-3. Boolean operations

Operation Example
NOT EXPR Not EXPR
EXPR1 OR EXPR2 logical OR
EXPR1 AND EXPR2 logical AND
EXPR1 == EXPR2 EXPR1 equals EXPR2


Conditional statement: IF( Test, ValueTrue, ValueFalse )

Examples:

Table 26-4. Expression examples

Expression Result Explanation
12+12 24 Addition
property=="Carsten" TRUE or FALSE String comparison between a Property and a string
"Erwin">"Carsten" TRUE A string compare is done