Expression Editor

The expression editor allows you to edit expressions in actions and conditions. An expression is a calculation using object properties like its position or angle, as shown at the top of the below image:


Formulation of an expression

An expression is a mathematical calculation: it can be composed of a simple number (e.g. 42), operators (e.g. 42+5*6), or functions like the random function (e.g. 42+Random(5)) or the position of an object (e.g. 42+MyObject.X()).

A function can be invoked by writing its name followed by parentheses, optionally containing the parameters to be sent to the function itself (e.g. Random(5)). In order to invoke the function of an object, add the object name and a dot before the function (e.g. MyObject.X()).


Help writing expressions

In the image above you can see a list of available operators and expressions: click to add one. You can also add properties in one of the two lists: click on Add, and fill out the parameters if necessary.


Some examples and helpful functions

  • You can convert text to numerical values using ToNumber. For example:
ToNumber(StrAt("157",Random(2)))

will give 1, 5 or 7 as result.

  • Random(x) will give a random number between 0 and x.

List of all mathematical operators and functions

Operators

Operator Description
-A Unary minus.
A*B Multiplication.
A/B Division.
A+B Sum.
A-B Subtraction.

Functions

Function Description Notes
abs(A) Absolute value. If A is negative, returns -A otherwise returns A.
acos(A) Arc-cosine. Returns the angle, measured in radians, whose cosine is A.
acosh(A) Hyperbolic cosine. Same as acos() but for hyperbolic cosine.
asin(A) Arc-sine. Returns the angle, measured in radians, whose sine is A.
asinh(A) Hyperbolic sine. Same as asin() but for hyperbolic sine.
atan(A) Arc-tangent. Returns the angle, measured in radians, whose tangent is (A).
atan2(A,B) Arc-tangent of A/B. The two main differences with atan() are that a) it will return the right angle depending on the signs of A and B (atan() can only return values betwen -pi/2 and pi/2), and that b) the return value of pi/2 and -pi/2 are possible.
atanh(A) Hyperbolic tangent. Same as atan(), but for hyperbolic tangent.
ceil(A) Ceiling. Returns the smallest integer greater than A. Rounds up to the next higher integer.
cos(A) Cosine in radiants. Returns the cosine of the angle A, where A is measured in radians.
cosh(A) Hyperbolic cosine. Same as cos(), but for hyperbolic cosine.
cot(A) Cotangent. Cotangent of A (equivalent to 1/tan(A)).
csc(A) Cosecant. Cosecant of A (equivalent to 1/sin(A)).
exp(A) Exponential. Returns the value of e raised to the power A where e is the base of the natural logarithm, i.e. the non-repeating value approximately equal to 2.71828182846.
floor(A) Floor. Returns the largest integer less than A. Rounds down to the next lower integer.
int(A) Round to integer. Rounds A to the closest integer. 0.5 is rounded to 1.
log(A) Natural logarithm. Natural (base e) logarithm of A.
log10(A) Base 10 logarithm. Base 10 logarithm of A.
max(A,B) Maximum. If A>B, the result is A, else B.
min(A,B) Minimum. If A<B, the result is A, else B.
mod(x,y) Modulo. Return the result of x mod y.
pow(A,B) Exponentiation A raised to the power B.
sec(A) Secant. Secant of A (equivalent to 1/cos(A)).
sin(A) Sine. Returns the sine of the angle A, where A is measured in radians.
sinh(A) Hyperbolic sine. Same as sin() but for hyperbolic sine.
sqrt(A) Square root. Returns the value whose square is A.
tan(A) Tangent. Returns the tangent of the angle A, where A is measured in radians.
tanh(A) Hyperbolic tangent. Same as tan() but for hyperbolic tangent.