class_@gdscript - dragonsoulz/godot GitHub Wiki

@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

sin

Standard sine function.

cos

Standard cosine function.

tan

Standard tangent function.

sinh

Hyperbolic sine.

cosh

Hyperbolic cosine.

tanh

Hyperbolic tangent.

asin

Arc-sine.

acos

Arc-cosine.

atan

Arc-tangent.

atan2

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

sqrt

Square root.

fmod

Module (remainder of x/y).

fposmod

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

floor

Floor (rounds down to nearest integer).

ceil

Ceiling (rounds up to nearest integer).

round

Round to nearest integer.

abs

Remove sign (works for integer and float).

sign

Return sign (-1 or +1).

pow

Power function, x elevate to y.

log

Natural logarithm.

exp

Exponential logarithm.

isnan

Return true if the float is not a number.

isinf

Return true if the float is infinite.

ease

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.

decimals

Return the amount of decimals in the floating point value.

stepify

Snap float value to a given step.

randomize

  • Nil randomize ( )

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

randi

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

randf

Random value (0 to 1 float).

rand_range

Random range, any floating point value between 'from' and 'to'

rand_seed

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

deg2rad

Convert from degrees to radians.

rad2deg

Convert from radias to degrees.

linear2db

Convert from linear energy to decibels (audio).

db2linear

Convert from decibels to linear energy (audio).

max

Return the maximum of two values.

min

Return the minimum of two values.

clamp

Clamp both values to a range.

nearest_po2

Return the nearest larger power of 2 for an integer.

weakref

Return a weak reference to an object.

convert

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

str

  • String str ( var what, var ... )

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

str

  • String str ( var what, var ... )

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

print

  • Nil print ( var what, var ... )

Print one or more arguments to strings in the best way possible to a console line.

printerr

  • Nil printerr ( var what, var ... )

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

printraw

  • Nil printraw ( var what, var ... )

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

range

  • Array range ( var ... )

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

load

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

inst2dict

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

dict2inst

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

print_stack

  • Nil print_stack ( )

Print a stack track at code location, only works when running with debugger turned on.