List of Built-in functions
Calculates the absolute value of a number
$.assert($.abs(-100) == 100)
Allowed by default: true
Calculates the arccos of a number
Calculates the arccosh of a number
Adds a Geometry Dash object or trigger to the target level
extract obj_props
$.add(obj {
OBJ_ID: 1,
X: 45,
Y: 45,
})
Allowed by default: true
The object or trigger to add
Appends a value to the end of an array. You can also use array.push(value)
let arr = []
$.append(arr, 1)
$.assert(arr == [1])
Allowed by default: true
Name
Type
arr
mutable Array
val
Calculates the arcsin of a number
Calculates the arcsinh of a number
Throws an error if the argument is not true
Calculates the arctan of a number
Calculates the arctan^2 of a number
Allowed by default: true
Name
Type
x
Number
y
Number
Calculates the arctanh of a number
Returns the input string decoded from base64 encoding (useful for text objects)
$.b64decode("aGVsbG8gdGhlcmU=")
Allowed by default: true
Returns the input string encoded with base64 encoding (useful for text objects)
$.b64encode("hello there")
Allowed by default: true
Calculates the cube root of a number
Calculates the ceil of a number, AKA the number rounded up to the nearest integer
$.assert($.ceil(1.5) == 2)
Allowed by default: true
Calculates the cos of an angle in radians
Calculates the cosh of a number
returns the value display string for the given value
$.display(counter()) // "counter(?i, bits = 16)"
Allowed by default: true
Changes the value of an object key. You can also use object.set(key, value)
extract obj_props
let object = color_trigger(BG, 0, 0, 0, 0.5)
$.edit_obj(object, X, 600)
Allowed by default: true
Name
Type
o, m
mutable Obj
key
value
Calculates the e^x of a number
Calculates the 2^x of a number
$.assert($.exp2(10) == 1024)
Allowed by default: true
Calculates e^x - 1 in a way that is accurate even if the number is close to zero
Executes a macro in a specific trigger function context
$.extend_trigger_func(10g, () {
11g.move(10, 0, 0.5) // will add a move trigger in group 10
})
Allowed by default: true
Name
Type
group
mac
Macro
Calculates the floor of a number, AKA the number rounded down to the nearest integer
$.assert($.floor(1.5) == 1)
Allowed by default: true
Gets the fractional part of a number
Gets some input from the user
// inp = $.get_input('What is your name?')
Allowed by default: true
Calculates the numerical hash of a value
Sends an HTTP request
Allowed by default: false
Name
Type
method
Str
url
Str
headers
Dict
body
Str
Calculates the hypothenuse in a right triangle with sides a and b
$.assert($.hypot(3, 4) == 5) // because 3^2 + 4^2 = 5^2
Allowed by default: true
Name
Type
a
Number
b
Number
Returns a array of the objects in the level being written to, or an empty array if there is no output level
level = $.level_objects()
Allowed by default: true
Returns the level string of the level being written to, or nothing if there is no output level
level_string = $.level_string()
Allowed by default: true
Calculates the ln (natural log) of a number
Calculates the log base x of a number
$.assert($.log(1024, 2) == 10)
Allowed by default: true
Name
Type
n
Number
base
Number
Calculates the max of two numbers
$.assert($.max(1, 2) == 2)
Allowed by default: true
Name
Type
a
Number
b
Number
Calculates the min of two numbers
$.assert($.min(1, 2) == 1)
Allowed by default: true
Name
Type
a
Number
b
Number
Checks if a value reference is mutable
const = 1
$.assert(!$.mutability(const))
let mut = 1
$.assert($.mutability(mut))
Allowed by default: true
Removes a value from the end of an array, and returns it. You can also use array.pop()
let arr = [1, 2, 3]
$.assert($.pop(arr) == 3)
$.assert(arr == [1, 2])
Allowed by default: true
Prints value(s) to the console
Allowed by default: true
any
Generates random numbers, or picks a random element of an array
$.random() // a completely random number
$.random([1, 2, 3, 6]) // returns either 1, 2, 3, or 6
$.random(1..11) // returns a random integer between 1 and 10
Allowed by default: true
see example
Returns the contents of a file in the local system (uses the current directory as base for relative paths)
data = $.readfile("file.txt")
Allowed by default: false
Path of file to read, and the format it's in ("text", "bin", "json", "toml" or "yaml")
Performs a regex operation on a string
Allowed by default: true
mode
can be either "match", "replace", "find_all" or "find_groups"
Name
Type
regex
Str
s
Str
mode
Str
replace
Removes a specific value from an array, string or dictionary. You can also use array.remove(index)
or dict.remove(key)
let names = ['James', 'Sophia', 'Romulus', 'Remus', 'Tiberius']
$.remove_index(names, 2)
$.assert(names == ['James', 'Sophia', 'Remus', 'Tiberius'])
let name_age = {
'Sophia': 34,
'Romulus': 14,
'Remus': 15,
}
$.remove_index(name_age, 'Romulus')
$.assert(name_age == {
'Sophia': 34,
'Remus': 15,
})
Allowed by default: true
Name
Type
arr
mutable
index
Rounds a number
$.assert($.round(1.2) == 1)
Allowed by default: true
Calculates the sin of an angle in radians
Calculates the hyperbolic sin of a number
Returns an array from the split string. You can also use string.split(delimiter)
$.assert($.split_str("1,2,3", ",") == ["1", "2", "3"])
Allowed by default: true
Name
Type
s
Str
substr
Str
Gets the current version of spwn
Allowed by default: true
none
Calculates the square root of a number
Returns a specified part of the input string
$.substr("hello there", 1, 5)
Allowed by default: true
Name
Type
val
Str
start_index
Number
end_index
Number
Calculates the tan of an angle in radians
Calculates the hyperbolic tan of a number
Gets the current system time in seconds
Allowed by default: true
none
Returns the start group of the current trigger function context
Allowed by default: true
none
Writes a string to a file in the local system (any previous content will be overwritten, and a new file will be created if it does not already exist)
$.write_file("file.txt", "Hello")
Allowed by default: false
Name
Type
path
Str
data
Str
Default Implementations for Operators
Default implementation of the +=
operator
let val = 25
$._add_(val, 10)
$.assert(val == 35)
Allowed by default: true
Default implementation of the &&
operator
Default implementation of the as
operator
Allowed by default: true
Name
Type
a
t
TypeIndicator
Default implementation of the =
operator
let val = 0
$._assign_(val, 64)
$.assert(val == 64)
Allowed by default: true
Default implementation of the &
operator
$._both_(@number, @counter)
Allowed by default: true
Default implementation of the n--
operator
let n = 1
$._decrement_(n)
$.assert(n == 0)
Allowed by default: true
Name
Type
a
mutable Number
returns the default value display string for the given value
$._display_(counter()) // "@counter::{ item: ?i, bits: 16 }"
Allowed by default: true
Default implementation of the /=
operator
let val = 9
$._divide_(val, 3)
$.assert(val == 3)
Allowed by default: true
Name
Type
a
mutable Number
b
Number
Default implementation of the /
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the |
operator
$._either_(@number, @counter)
Allowed by default: true
Default implementation of the ==a
operator
$.assert(10 is $._eq_pattern_(10))
Allowed by default: true
Default implementation of the ==
operator
$._equal_("hello", "hello")
Allowed by default: true
Default implementation of the ^=
operator
let val = 3
$._exponate_(val, 3)
$.assert(val == 27)
Allowed by default: true
Name
Type
a
mutable Number
b
Number
Default implementation of the in
operator
Default implementation of the in a
operator
$.assert(10 is $._in_pattern_([8, 10, 12]))
Allowed by default: true
Default implementation of the n++
operator
let n = 0
$._increment_(n)
$.assert(n == 1)
Allowed by default: true
Name
Type
a
mutable Number
Default implementation of the /%=
operator
let val = 10
$._intdivide_(val, 3)
$.assert(val == 3)
Allowed by default: true
Name
Type
a
mutable Number
b
Number
Default implementation of the /%
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the is
operator
$._is_([1, 2, 3], [@number])
Allowed by default: true
Default implementation of the <=a
operator
$.assert(10 is $._less_or_eq_pattern_(10))
Allowed by default: true
Default implementation of the <=
operator
$._less_or_equal_(100, 100)
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the <a
operator
$.assert(10 is $._less_pattern_(11))
Allowed by default: true
Default implementation of the <
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the -
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the %
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the %=
operator
let val = 10
$._modulate_(val, 3)
$.assert(val == 1)
Allowed by default: true
Name
Type
a
mutable Number
b
Number
Default implementation of the >=a
operator
$.assert(10 is $._more_or_eq_pattern_(10))
Allowed by default: true
Default implementation of the >=
operator
$._more_or_equal_(100, 100)
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the >a
operator
$.assert(10 is $._more_pattern_(9))
Allowed by default: true
Default implementation of the >
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the *=
operator
let val = 5
$._multiply_(val, 10)
$.assert(val == 50)
Allowed by default: true
Name
Type
a
mutable
b
Number
Default implementation of the -n
operator
$.assert($._negate_(1) == -1)
Allowed by default: true
Default implementation of the !b
operator
Default implementation of the !=a
operator
$.assert(10 is $._not_eq_pattern_(5))
Allowed by default: true
Default implementation of the !=
operator
$._not_equal_("hello", "bye")
Allowed by default: true
Default implementation of the ||
operator
Default implementation of the +
operator
Default implementation of the ^
operator
Allowed by default: true
Name
Type
a
Number
b
Number
Default implementation of the --n
operator
let n = 1
$.assert($._pre_decrement_(n) == 0)
Allowed by default: true
Name
Type
a
mutable Number
Default implementation of the ++n
operator
let n = 0
$.assert($._pre_increment_(n) == 1)
Allowed by default: true
Name
Type
a
mutable Number
Default implementation of the ..
operator
Default implementation of the -=
operator
let val = 25
$._subtract_(val, 10)
$.assert(val == 15)
Allowed by default: true
Name
Type
a
mutable Number
b
Number
Default implementation of the <=>
operator
let a = 10
let b = 5
$._swap_(a, b)
$.assert(a == 5)
$.assert(b == 10)
Allowed by default: true
Name
Type
a
mutable
b
mutable
Default implementation of the *
operator