Built-in GDScript functions.
- PI = 3.141593 — Constant that represents how many times the diameter of a circumference fits around its perimeter.
- INF = inf
- NAN = nan
This contains the list of built-in gdscript functions. Mostly math functions and other utilities. Everything else is expanded by objects.
Member Function Description¶
Make a color from red, green, blue and alpha. Arguments can range from 0 to 255.
Remove sign (works for integer and float).
Assert that the condition is true. If the condition is false, generates an error.
Arc-tangent that takes a 2D vector as argument, returns the full -pi to +pi range.
Decode a byte array back to a value.
Ceiling (rounds up to nearest integer).
Clamp both values to a range.
Convert from a type to another in the best way possible. The “type” parameter uses the enum TYPE_* in @Global Scope.
Standard cosine function.
Convert from decibels to linear energy (audio).
Return the amount of decimals in the floating point value.
Decreases time by a specified amount.
Convert from degrees to radians.
Convert a previously converted instances to dictionary back into an instance. Useful for deserializing.
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
Floor (rounds down to nearest integer).
Module (remainder of x/y).
Module (remainder of x/y) that wraps equally in positive and negative.
Return a reference to the specified function.
Hash the variable passed and return an integer.
Convert a script class instance to a dictionary (useful for serializing).
Get an object by its ID.
Linear interpolates between two values by a normalized value.
Convert from linear energy to decibels (audio).
Load a resource from the filesystem, pass a valid path as argument.
Return the maximum of two values.
Return the minimum of two values.
Return the nearest larger power of 2 for an integer.
Parse json text to a Variant (use typeof to check if it is what you expect).
Power function, x elevate to y.
Preload a resource from the filesystem. The resource is loaded during script parsing.
Print one or more arguments to strings in the best way possible to a console line.
- Nil print_stack ( )
Print a stack track at code location, only works when running with debugger turned on.
Print one or more arguments to strings in the best way possible to standard error line.
Print one or more arguments to strings in the best way possible to console. No newline is added at the end.
Print one or more arguments to the console with a space between each argument.
Print one or more arguments to the console with a tab between each argument.
Convert from radians to degrees.
Random range, any floating point value between ‘from’ and ‘to’.
Random from seed: pass a seed, and an array with both number and new seed is returned. “Seed” here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
- float randf ( )
Return a random floating point value between 0 and 1.
- int randi ( )
Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use remainder. For example, to get a random integer between 0 and 19 inclusive, you can use randi() % 20.
- Nil randomize ( )
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
Return an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment).
Round to nearest integer.
Set seed for the random number generator.
Return sign (-1 or +1).
Standard sine function.
Snap float value to a given step.
Convert one or more arguments to strings in the best way possible.
Convert a formatted string that was returned by var2str to the original value.
Standard tangent function.
Convert a Variant to json text.
Return the internal type of the given Variant object, using the TYPE_* enum in @Global Scope.
Encode a variable value to a byte array.
Convert a value to a formatted string that can later be parsed using str2var.
Return a weak reference to an object.
Stop the function execution and return the current state. Call GDFunctionState.resume on the state to resume execution. This invalidates the state.
Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object’s signal is emitted.