Skip to main content

Expressions

Every number or text field in an event is an expression: a small formula the game works out while it runs. Type 10, Score + 1, "Score: " + Score, Player.x or random(1, 6).

Values and operators​

WriteMeaning
12, 3.5, -1Numbers
"text" or 'text'Text (with quotes)
true, falseYes / no
+ - * / % , ^, modMath. + joins text when either side is text: "Lives: " + Lives
= <> != ≠ < <= ≤ > >= ≥Compare (gives true/false)
and or not (also & | !)Logic
cond ? a : bPick a or b
ScoreA global, scene or local variable, by name
Player.xA property of an object (see below)
Enemy.hpAn instance variable (also Enemy.var("hp"))
Mistakes don’t crash the game

If you mistype a name, the game keeps running: it shows a friendly message once and the unknown value counts as 0. The event with the problem gets a red badge in the editor.

Functions​

Random​

FunctionWhat it does
random(min, max)Random decimal number between min and max
randomInt(min, max)Random whole number from min to max (inclusive)
choose(a, b, ...)Picks one of the values at random

Game​

FunctionWhat it does
loopindex("i")Current number of the loop called "i" (For loop), or of the innermost loop without a name
timeSeconds since the scene started
dtSeconds since the last frame (multiply speeds by dt)
fpsFrames per second
loopIndexCurrent number of the innermost loop (Repeat, For, For each, While)
screenWidthScreen width in pixels
screenHeightScreen height in pixels

Math​

FunctionWhat it does
abs(x)Absolute value (removes the minus sign)
min(a, b, ...)Smallest value
max(a, b, ...)Largest value
floor(x)Round down
ceil(x)Round up
round(x, digits?)Round to nearest (optionally to N decimals)
sqrt(x)Square root
pow(x, y)x to the power of y (same as x ^ y)
sign(x)-1, 0 or 1
sin(degrees)Sine (angle in degrees)
cos(degrees)Cosine (angle in degrees)
tan(degrees)Tangent (angle in degrees)
atan2(y, x)Angle in degrees of the vector (x, y)
angle(x1, z1, x2, z2)Angle (degrees, around Y) from point 1 to point 2
lerp(a, b, t)Blend from a to b (t from 0 to 1)
clamp(x, min, max)Keep x between min and max
distance(x1, z1, x2, z2)Distance on the ground (X/Z) between two points
distance3(x1, y1, z1, x2, y2, z2)3D distance between two points

Convert​

FunctionWhat it does
int(x)Whole number part (drops decimals)
float(x)Convert text to a number
str(x)Convert a number to text

Text​

FunctionWhat it does
len(text)Number of characters in a text
upper(text)UPPERCASE text
lower(text)lowercase text
left(text, count)First characters of a text
right(text, count)Last characters of a text
mid(text, start, count)Part of a text
contains(text, part)true if text contains part
replace(text, find, with)Replace every occurrence
pad(value, length, char?)Pad with leading zeros, e.g. 007

Input​

FunctionWhat it does
touchXFinger X position on screen
touchYFinger Y position on screen
joystickXJoystick left/right (-1 to 1)
joystickYJoystick down/up (-1 to 1)

Object properties​

Write the object’s name (or Self inside an action on that object), a dot, then the property: Player.x, Coin.count, Self.angle.

PropertyWhat it gives
.xX position
.yY position (height)
.zZ position
.angleTurn angle around Y (degrees)
.rotXRotation X (degrees)
.rotYRotation Y (degrees)
.rotZRotation Z (degrees)
.scaleXScale X
.scaleYScale Y
.scaleZScale Z
.vxVelocity X
.vyVelocity Y
.vzVelocity Z
.speedSpeed (length of velocity)
.countNumber of these objects in the scene
.pickedCountNumber of picked instances in this event
.worldXWorld X position
.worldYWorld Y position
.worldZWorld Z position
.textText shown (text objects)
.visibletrue if visible
.nameObject name
.idUnique id of the instance
.valueProgress bar value (UI)
.maxProgress bar maximum (UI)
.pressedUI button is held down

Inside an action on an object type, Coin.x means the coin being processed. With several picked coins, the action runs once per coin and each sees its own values.

Built-in values​

time · dt · fps · screenWidth · screenHeight · touchX · touchY · touching · joystickX · joystickY · loopIndex · timeScale

Compare operators​

Conditions such as Compare variable use: = ≠ < ≤ > ≥