@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

Color Color8 ( int r8, int g8, int b8, int a8 )

Make a color from red, green, blue and alpha. Arguments can range from 0 to 255.

Color ColorN ( String name, float alpha )

float abs ( float s )

Remove sign (works for integer and float).

float acos ( float s )

Arc-cosine.

float asin ( float s )

Arc-sine.

Nil assert ( bool condition )

Assert that the condition is true. If the condition is false, generates an error.

float atan ( float s )

Arc-tangent.

float atan2 ( float x, float y )

Arc-tangent that takes a 2D vector as argument, returns the full -pi to +pi range.

Variant bytes2var ( RawArray bytes )

Decode a byte array back to a value.

float ceil ( float s )

Ceiling (rounds up to nearest integer).

float clamp ( float val, float min, float max )

Clamp both values to a range.

Object convert ( Variant what, int type )

Convert from a type to another in the best way possible. The “type” parameter uses the enum TYPE_* in @Global Scope.

float cos ( float s )

Standard cosine function.

float cosh ( float s )

Hyperbolic cosine.

float db2linear ( float db )

Convert from decibels to linear energy (audio).

float decimals ( float step )

Return the amount of decimals in the floating point value.

float dectime ( float value, float amount, float step )

Decreases time by a specified amount.

float deg2rad ( float deg )

Convert from degrees to radians.

Object dict2inst ( Dictionary dict )

Convert a previously converted instances to dictionary back into an instance. Useful for deserializing.

float ease ( float s, float curve )

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.

float exp ( float s )

Exponential logarithm.

float floor ( float s )

Floor (rounds down to nearest integer).

float fmod ( float x, float y )

Module (remainder of x/y).

float fposmod ( float x, float y )

Module (remainder of x/y) that wraps equally in positive and negative.

FuncRef funcref ( Object instance, String funcname )

Return a reference to the specified function.

int hash ( Variant var:Variant )

Hash the variable passed and return an integer.

Dictionary inst2dict ( Object inst )

Convert a script class instance to a dictionary (useful for serializing).

Object instance_from_id ( int instance_id )

Get an object by its ID.

float is_inf ( float s )

float is_nan ( float s )

float lerp ( float from, float to, float weight )

Linear interpolates between two values by a normalized value.

float linear2db ( float nrg )

Convert from linear energy to decibels (audio).

Resource load ( String path )

Load a resource from the filesystem, pass a valid path as argument.

float log ( float s )

Natural logarithm.

float max ( float a, float b )

Return the maximum of two values.

float min ( float a, float b )

Return the minimum of two values.

int nearest_po2 ( int val )

Return the nearest larger power of 2 for an integer.

float pow ( float x, float y )

Power function, x elevate to y.

Resource preload ( String path )

Preload a resource from the filesystem. The resource is loaded during script parsing.

Nil print ( Variant what, Variant ... )

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.

Nil printerr ( Variant what, Variant ... )

Print one or more arguments to strings in the best way possible to standard error line.

Nil printraw ( Variant what, Variant ... )

Print one or more arguments to strings in the best way possible to console. No newline is added at the end.

Nil prints ( Variant what, Variant ... )

Print one or more arguments to the console with a space between each argument.

Nil printt ( Variant what, Variant ... )

Print one or more arguments to the console with a tab between each argument.

float rad2deg ( float rad )

Convert from radians to degrees.

float rand_range ( float from, float to )

Random range, any floating point value between ‘from’ and ‘to’

Array rand_seed ( int seed )

Random from seed, pass a seed and an array with both number and new seed is returned.

float randf ( )

Random value (0 to 1 float).

int randi ( )

Random 32 bits value (integer). To obtain a value from 0 to N, you can use remainder, like (for random from 0 to 19): randi() % 20.

Nil randomize ( )

Reset the seed of the random number generator with a new, different one.

Array range ( Variant ... )

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

float round ( float s )

Round to nearest integer.

Nil seed ( int seed )

Set seed for the random number generator.

float sign ( float s )

Return sign (-1 or +1).

float sin ( float s )

Standard sine function.

float sinh ( float s )

Hyperbolic sine.

float sqrt ( float s )

Square root.

float stepify ( float s, float step )

Snap float value to a given step.

String str ( Variant what, Variant ... )

Convert one or more arguments to strings in the best way possible.

Variant str2var ( String string )

Convert a formatted string that was returned by var2str to the original value.

float tan ( float s )

Standard tangent function.

float tanh ( float s )

Hyperbolic tangent.

bool type_exists ( String type )

int typeof ( Variant what )

Return the internal type of the given Variant object, using the TYPE_* enum in @Global Scope.

RawArray var2bytes ( Variant var )

Encode a variable value to a byte array.

String var2str ( Variant var )

Convert a value to a formatted string that can later be parsed using str2var.

WeakRef weakref ( Object obj )

Return a weak reference to an object.

GDFunctionState yield ( Object object, String signal )

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

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/2.1/classes/[email protected]