Built-in GDScript functions.
- PI = 3.141593 — Constant that represents how many times the diameter of a circumference fits around its perimeter.
- INF = inf — A positive infinity. (For negative infinity, use -INF).
- NAN = nan — Macro constant that expands to an expression of type float that represents a NaN.
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
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.
Returns the absolute value of parameter s (i.e. unsigned value, works for integer and float).
Returns the principal value of the arc cosine of s, expressed in radians. In trigonometrics, arc cosine is the inverse operation of cosine.
Returns the principal value of the arc sine of s, expressed in radians. In trigonometrics, arc sine is the inverse operation of sine.
- void assert ( bool condition )
Assert that the condition is true. If the condition is false, generates an error.
Returns the principal value of the arc tangent of s, expressed in radians. In trigonometrics, arc tangent is the inverse operation of tangent. Notice that because of the sign ambiguity, the function cannot determine with certainty in which quadrant the angle falls only by its tangent value. See atan2 for an alternative that takes a fractional argument instead.
Returns the principal value of the arc tangent of y/x, expressed in radians. To compute the value, the function takes into account the sign of both arguments in order to determine the quadrant.
Decode a byte array back to a value.
Rounds s upward, returning the smallest integral value that is not less than s.
Clamps a value between a minimum and maximum value.
Convert from a type to another in the best way possible. The “type” parameter uses the enum TYPE_* in @Global Scope.
Returns the cosine of an angle of s radians.
Returns the hyperbolic cosine of s.
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.
Returns the base-e exponential function of s, which is e raised to the power s: e^s.
Rounds s downward, returning the largest integral value that is not greater than s.
Returns the floating-point remainder of x/y (rounded towards zero):
fmod = x - tquot \* y
Where tquot is the truncated (i.e., rounded towards zero) result 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.
Returns whether s is an infinity value (either positive infinity or negative infinity).
Returns whether s is a NaN (Not-A-Number) value.
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).
Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert every numerical values to float types.
Power function, x elevate to y.
Preload a resource from the filesystem. The resource is loaded during script parsing.
- void print ( ) vararg
Print one or more arguments to strings in the best way possible to a console line.
- void print_stack ( )
Print a stack track at code location, only works when running with debugger turned on.
- void printerr ( ) vararg
Print one or more arguments to strings in the best way possible to standard error line.
- void printraw ( ) vararg
Print one or more arguments to strings in the best way possible to console. No newline is added at the end.
- void prints ( ) vararg
Print one or more arguments to the console with a space between each argument.
- void printt ( ) vararg
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.
- void randomize ( )
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
- Array range ( ) vararg
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).
Returns the integral value that is nearest to s, with halfway cases rounded away from zero.
- void seed ( int seed )
Set seed for the random number generator.
Return sign (-1 or +1).
Returns the sine of an angle of s radians.
Returns the hyperbolic sine of s.
Returns the square root of s.
Snap float value to a given step.
- String str ( ) vararg
Convert one or more arguments to string in the best way possible.
Convert a formatted string that was returned by var2str to the original value.
Returns the tangent of an angle of s radians.
Returns the hyperbolic tangent of s.
Convert a Variant to json text.
Return the internal type of the given Variant object, using the TYPE_* enum in @Global Scope.
This method is used to validate the structure and data types of a piece of JSON, similar to XML Schema for XML.
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.
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
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.