Table of Contents

Common available functions

Abs(Number) -> Number

Calculates the absolute value.

Abs(-2) = 2

Min(Number, Number) -> Number

Returns the minimum value of the two inputs.

Min(10, 3) = 3

Min(Number[]) -> Number

Returns the minimum value in an array of numbers.

Min([10, -3, 2]) = -3

Max(Number, Number) -> Number

Returns the maximum value of the two inputs.

Max(10, 3) = 10

Max(Number[]) -> Number

Returns the maximum value in an array of numbers.

Max([10, -3, 2]) = 10

Clamp(Number, min: Number, max: Number) -> Number

Clamps the number in the range between min and max.

Clamp(4, -10, 10) = 4
Clamp(-125, -10, 10) = -10

Round(Number) -> Number

Rounds the value to the nearest integer.

Round(12.45) = 12
Round(12.8) = 13

Ceiling(Number) -> Number

Rounds the value up to the nearest integer.

Ceiling(12.45) = 13
Ceiling(12.8) = 13

Floor(Number) -> Number

Rounds the value down to the nearest integer.

Floor(12.45) = 12
Floor(12.8) = 12

Fraction(Number) -> Number

Returns the fractional part of the number.

Fraction(12.45) = 0.45

Mod(Number, Number) -> Number

Returns the remainder when first argument is being divided by the second.

Mod(10, 3) = 1

Sign(Number) -> Number

Returns -1 for negative, 1 for positive and 0 for zero input.

Sign(5) = 1
Sign(0) = 0
Sign(-12) = -1

Sqrt(Number) -> Number

Returns the square root of the input.

Sqrt(16) = 4

Exp(Number) -> Number

Calculates the natural exponentiation of a given number.

Pow(Number, exponent: Number) -> Number

Raises the first argument to the power of the second argument.

Pow(2, 5) = 32

Log(Number) -> Number

Natural logarithm function.

Log(Number, base: Number) -> Number

Calculates logarithm in a given base.

ToDegrees(Number) -> Number

Converts radians to degrees.

ToRadians(Number) -> Number

Converts degrees to radians.

Sin(Number) -> Number

Trigonometric sin function. Input angle is in radians.

Cos(Number) -> Number

Trigonometric cos function. Input angle is in radians.

Tan(Number) -> Number

Trigonometric tan function. Input angle is in radians.

Asin(Number) -> Number

Trigonometric inverse sin function. Output angle is in radians.

Acos(Number) -> Number

Trigonometric inverse cos function. Output angle is in radians.

Atan(Number) -> Number

Trigonometric inverse tan function. Output angle is in radians.

Sum(Number[]) -> Number

Calculates the sum of elements in a vector or an array.

Sum([10, -3, 2, 5]) = 14

Length(Number[]) -> Number

Calculates the length of a vector.

Length([3, 4]) = 5

LengthSquared(Number[]) -> Number

Calculates the length squared of a vector. This is faster to calculate than the length in cases where the exact length value is not needed, like when comparing lengths of two vectors.

LengthSquared([2, 6]) = 40
LengthSquared([2, 6]) > LengthSquared([3, 4]) = true

Dot(Number[N], Number[N]) -> Number

Calculates the dot product of two vectors. The vectors must be the same length.

Dot([2, 3], [-1, 4]) = 10

Cross(Number[3], Number[3]) -> Number[3]

Calculates the cross product of two three-dimensional vectors.

Mix(number1: Number, number2: Number, amount: Number) -> Number

Linearly interpolates between number1 and number2 based on the amount (usually in range 0.0 - 1.0)

Mix(2, 10, 0.0) = 2
Mix(2, 10, 0.5) = 6
Mix(2, 10, 1.0) = 10

SmoothStep(min: Number, max: Number, x: Number) -> Number

Calculates the Hermite interpolation between two values.

Normalized(Number[N]) -> Number[N]

Normalizes a numeric vector.

Normalized([3, 4]) = [0.6, 0.8]

Distance(Number[N], Number[N]) -> Number

Calculates the distance between two points. The vectors must be the same length.

Distance([2, 3], [5, 7]) = 5

DistanceSquared(Number[N], Number[N]) -> Number

Calculates the squared distance between two points (avoids square root). The vectors must be the same length.

DistanceSquared([2, 3], [5, 7]) = 25

AngleBetween(Number[N], Number[N]) -> Number

Calculates the angle between two direction vectors in radians. The vectors must be the same length.

Average(Number[]) -> Number

Calculates the arithmetic mean of a numeric array. Fails on empty input.

Average([2, 4, 6]) = 4

Range(start: Number, endInclusive: Number) -> Number[]

Generates a sequence of numbers with a default step of 1. End value is included if reachable exactly.

Range(1, 5) = [1, 2, 3, 4, 5]
Range(5, 1) = []

Range(start: Number, endInclusive: Number, step: Number) -> Number[]

Generates a sequence of numbers with a custom non-zero step. Direction must match step sign. End value is included if reached exactly.

Range(5, 1, -2) = [5, 3, 1]
Range(0, 1, 0.5) = [0, 0.5, 1]

Reverse(Any[N]) -> Any[N]

Reverses the order of elements in an vector or array.

Reverse([1, 2, 3]) = [3, 2, 1]
Reverse([100, true, "Text"]) = ["Text", true, 100]

Append(Any[N], Any) -> Any[N+1]

Appends a single element to the end of the vector.

Append([1, 2, 3], 4) = [1, 2, 3, 4]

Prepend(Any[N], Any) -> Any[N+1]

Adds a single element to the start of the vector.

Prepend([2, 3, 4], 1) = [1, 2, 3, 4]

Concat(Any[M], Any[N]) -> Any[M+N]

Concatenates two vectors.

Concat([1, 2], [3, 4]) = [1, 2, 3, 4]

Repeat(Any[N], times: Number) -> Any[N*times]

Repeats a whole vector a given non-negative number of times (fractional part is discarded).

Repeat([1, 2], 3) = [1, 2, 1, 2, 1, 2]

RepeatValue(Any, times: Number) -> Any[times]

Creates a new vector repeating a single value.

RepeatValue(5, 4) = [5, 5, 5, 5]
RepeatValue("Hi", 3) = ["Hi", "Hi", "Hi"]

Skip(Any[], count: Number) -> Any[]

Skips a number of elements from the start.

Skip([1, 2, 3, 4, 5], 2) = [3, 4, 5]

SkipLast(Any[N], count: Number) -> Any[...]

Skips a number of elements from the end.

SkipLast([1, 2, 3, 4, 5], 2) = [1, 2, 3]

Take(Any[N], count: Number) -> Any[...]

Takes up to count elements from the start.

Take([1, 2, 3, 4, 5], 3) = [1, 2, 3]

TakeLast(Any[N], count: Number) -> Any[...]

Takes up to count elements from the end.

TakeLast([1, 2, 3, 4, 5], 2) = [4, 5]

Slice(Any[N], start: Number, length: Number) -> Any[...]

Extracts a sub-range starting at index start with given length (both floored). Clamped to bounds.

Slice([10, 20, 30, 40, 50], 1, 3) = [20, 30, 40]

Count(Any[N]) -> Number

Returns number of elements.

Count([10, 20]) = 2
Count([100, true, "Text"]) = 3
Count([]) = 0

IndexOf(Any[N], Any) -> Number

Returns first index of a structurally equal value or -1 if not found.

IndexOf(["a", "b", "c", "b"], "b") = 1
IndexOf(["a", "b"], "x") = -1

Contains(Any[N], Any) -> Boolean

Returns true if value exists in the vector.

Contains(["a", "b", "c"], "b") = true
Contains(["a", "b", "c"], "x") = false

IndexOfArray(Any[N], Any[N]) -> Number

Returns the first index where the second array appears as a contiguous subarray in the first array, or -1 if not found.

IndexOfArray(["a", "b", "c", "b", "c"], ["b", "c"]) = 1
IndexOfArray(["a", "b", "c"], ["b", "x"]) = -1

ContainsArray(Any[N], Any[N]) -> Boolean

Returns true if the second array appears as a contiguous subarray in the first array.

ContainsArray(["a", "b", "c", "b", "c"], ["b", "c"]) = true
ContainsArray(["a", "b", "c"], ["b", "x"]) = false

Any(Any[N]) -> Boolean

Returns true if any element is truthy.

Any([0, "", false, 5]) = true
Any([0, "", false]) = false

All(Any[N]) -> Boolean

Returns true if all elements are truthy.

All([1, "Hi", true]) = true
All([1, "", true]) = false

IsEmpty(Any[N]) -> Boolean

Returns true if the vector has zero elements.

IsEmpty([]) = true
IsEmpty([1]) = false

PropertyValues(items: Any[N], propertyName: String) -> (items[propertyName])[N]

Maps an array of objects or records to the value of a single property on each item.

The propertyName argument must be a compile-time constant string.

If an item does not contain the requested property, or if the item does not support property access, the result contains null in that position instead of failing the script.

The result element type is inferred from the possible property types on the input items. If some items can produce no value for the requested property, null is included in the result type.

PropertyValues([PartA, PartB], "Name") = ["PartA", "PartB"]
PropertyValues(Connectors, "IsConnected") = [true, false, true]
PropertyValues([obj1, obj2, obj3], "MyProperty") = ["value1", null, "value3"]