@GDScript¶
Category: Core
Brief Description¶
Built-in GDScript functions.
Member Functions¶
Numeric Constants¶
- PI = 3.141593 — Constant that represents how many times the diameter of a circumference fits around it’s 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.
Remove sign (works for integer and float).
Arc-cosine.
Arc-sine.
Assert that the condition is true. If the condition is false, generates an error.
Arc-tangent.
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.
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.
Hyperbolic cosine.
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.
- Object dict2inst ( Dictionary dict )
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.
Exponential logarithm.
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.
- 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).
Get an object by its ID.
Return true if the float is infinite.
Return true if the float is not a number.
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.
Power function, x elevate to y.
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.
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.
- 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).
Round to nearest integer.
Set seed for the random number generator.
Return sign (-1 or +1).
Standard sine function.
Hyperbolic sine.
Square root.
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.
Standard tangent function.
Hyperbolic tangent.
- 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.
Return a weak reference to an object.
Stop the function execution and return the current state. Call resume on the state to resume execution. This makes the state invalid.
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.