@GDScript

Category: Core

Brief Description

Built-in GDScript functions.

Member Functions

Color Color8 ( int r8, int g8, int b8, int a8 )
Color ColorN ( String name, float alpha )
float abs ( float s )
float acos ( float s )
float asin ( float s )
Nil assert ( bool condition )
float atan ( float s )
float atan2 ( float x, float y )
Variant bytes2var ( RawArray bytes )
float ceil ( float s )
float clamp ( float val, float min, float max )
Object convert ( Variant what, int type )
float cos ( float s )
float cosh ( float s )
float db2linear ( float db )
float decimals ( float step )
float dectime ( float value, float amount, float step )
float deg2rad ( float deg )
Object dict2inst ( Dictionary dict )
float ease ( float s, float curve )
float exp ( float s )
float floor ( float s )
float fmod ( float x, float y )
float fposmod ( float x, float y )
FuncRef funcref ( Object instance, String funcname )
int hash ( Variant var:Variant )
Dictionary inst2dict ( Object inst )
Object instance_from_id ( int instance_id )
float is_inf ( float s )
float is_nan ( float s )
float lerp ( float from, float to, float weight )
float linear2db ( float nrg )
Resource load ( String path )
float log ( float s )
float max ( float a, float b )
float min ( float a, float b )
int nearest_po2 ( int val )
float pow ( float x, float y )
Resource preload ( String path )
Nil print ( Variant what, Variant)
Nil print_stack ( )
Nil printerr ( Variant what, Variant)
Nil printraw ( Variant what, Variant)
Nil prints ( Variant what, Variant)
Nil printt ( Variant what, Variant)
float rad2deg ( float rad )
float rand_range ( float from, float to )
Array rand_seed ( int seed )
float randf ( )
int randi ( )
Nil randomize ( )
Array range ( Variant)
float round ( float s )
Nil seed ( int seed )
float sign ( float s )
float sin ( float s )
float sinh ( float s )
float sqrt ( float s )
float stepify ( float s, float step )
String str ( Variant what, Variant)
Variant str2var ( String string )
float tan ( float s )
float tanh ( float s )
bool type_exists ( String type )
int typeof ( Variant what )
RawArray var2bytes ( Variant var )
String var2str ( Variant var )
WeakRef weakref ( Object obj )
GDFunctionState yield ( Object object, String signal )

Numeric Constants

  • PI = 3.141593 — Constant that represents how many times the diameter of a circumference fits around its perimeter.

Description

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).

  • Object instance_from_id ( int instance_id )

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.

Natural logarithm.

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.

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.

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.

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.