Functions
A random number
RAND()
no parameters
Generates a random number
RAND
()
will output a random value between 0 and 1, e.g. 0.625
RAND
()*10
will output a random value between 0 and 10, e.g. 6.25
Rounded number
ROUND
(value, digits)
value (Number): the number to be rounded.
digits (Integer): the number of decimal places to round to.
Rounds a number to the specified number of decimal places
Example: ROUND
(3.14159, 2)
→ 3.14
Number of characters in the string, including spaces
LEN
("value")
value (String): the input string whose length is to be determined
Returns the length of a string
LEN
("hello")
will output a value of 5
Either trueValue
or falseValue
depending on the condition
IF
(condition,trueValue,falseValue)
condition (Expression): A logical expression that evaluates to true or false
trueValue (Any): The value returned if the condition is true
falseValue (Any): The value returned if the condition is false
Returns one value if a condition is true and another value if it is false
IF
(
temperature
<
10, “cold”, “hot")
if
temperature
=
5
, the result is "cold", but if temperature
=
15
, the result is "hot".
Result of the evaluated expression
EVAL
(expression)
Re-evaluates a string as an expression and returns the result. expression (String): a valid expression in string format to be evaluated.
EVAL
(”5
+
5”)
=
10
Numeric value represented by the string, or an error if the conversion is not possible
TO_NUMBER
(value)
Converts a string to its numerical representation, if possible.
TO_NUMBER
(”5”) returns the number representation of the string, in this case 5, if possible.
If the input is not a valid number (e.g., "abc"), it returns an error.
Time passed between frames as a floating-point number, typically measured in seconds
DELTA_TIME
Retrieves the time elapsed between the current frame and the previous frame. Commonly used in “on update” interactions to ensure smooth and consistent motion or timing.
If DELTA_TIME
returns 0.016
(16 milliseconds), it can be used for animations or movement calculations: position += speed * DELTA_TIME
Value from the target range that corresponds to the key in the lookup range
XLOOKUP
(dataset, key, lookupRange, targetRange)
dataset (Array)
the dataset containing the lookup and target ranges.
key (Any)
the value to search for in the lookup range.
lookupRange (Array)
the range where the key will be searched.
targetRange (Array)
the range from which the corresponding value will be returned.
Searches for a key in a lookup range and returns the corresponding value from a target range.
XLOOKUP
(salesData, "Product A", salesData["Products"], salesData["Revenue"]) → Returns the revenue associated with "Product A"
Value of the specified property from the target entity, which could include objects, settings, or other accessible data types
GET
(target, propertyName)
Retrieves the value of a specified property from a target entity. This can be used to access various attributes, settings, or metadata across different types of objects or entities.
GET
(
OBJ
("Box"), "position")
→ Retrieves the position of the object named "Box”
Reference to the specified object, which can then be used in other functions or operations
OBJ
(name)
name (String)
the name of the object to retrieve
Retrieves a reference to an object by its name. This is used to interact with specific objects.
OBJ
("Box") → Retrieves the object named "Box" for further interaction
UI
Same as above
VAR
Same as above
PARENT_OF
Same as above
CHILDREN_OF
Same as above
Contextual reference to the current object, component, or environment
SELF
In an interaction, returns the trigger
TRIGGER
In an interaction, returns the trigger or event that initiated the action.
Interaction: trigger ”on click”, action “set variable” → TRIGGER() will return the object name clicked
Scalar value representing the dot product of the two vectors. A positive result indicates alignment, zero indicates perpendicularity, and a negative result indicates opposing directions
DOT
(v1, v2)
v1 (Vector)
the first input vector
v2 (Vector)
the second input vector
Calculates the dot product of two vectors. The dot product is a scalar value that represents the magnitude of one vector projected onto another.
DOT
([1, 0, 0], [0, 1, 0])
→ 0 (vectors are perpendicular)
Vector that is perpendicular to both input vectors
CROSS
(v1, v2)
Calculates the cross product of two vectors. The cross product results in a new vector that is perpendicular to both input vectors and represents the area of the parallelogram formed by the vectors.
CROSS
([1, 0, 0], [0, 1, 0]) → [0, 0, 1]
a vector perpendicular to both input vectors
Scalar value representing the length of the vector
MAGNITUDE
(vector)
Calculates the magnitude (length) of a vector. The magnitude represents the distance of the vector from the origin in space.
MAGNITUDE
([3, 4, 0])
→ 5 (calculated as √(3² + 4² + 0²))
Unit vector with the same direction as the input vector but a magnitude of 1
NORMALIZE
(vector)
Converts a vector into a unit vector (a vector with a magnitude of 1) while maintaining its direction.
NORMALIZE
([3, 4, 0])
→ [0.6, 0.8, 0] (calculated by dividing each component by the magnitude, √(3² + 4² + 0²) = 5).
A value or vector between v1
and v2 based on the interpolation factor factor
LERP
(v1, v2, factor)
v1 (Number or Vector)
the starting value or vector of the interpolation
v2 (Number or Vector)
the ending value or vector of the interpolation
factor (Number)
the interpolation factor, a value between 0 and 1, where 0 represents v1
and 1 represents v2
Performs linear interpolation between two values or vectors based on a given ratio.
LERP
([0, 0], [10, 10], 0.5)
→ [5, 5] (halfway between the two vectors)
Last updated