@GDScript

Built-in GDScript constants, functions, and annotations.

Description

A list of GDScript-specific utility functions and annotations accessible from any script.

For the list of the global functions and constants see @GlobalScope.

Tutorials

Methods

Color

Color8 ( int r8, int g8, int b8, int a8=255 )

void

assert ( bool condition, String message="" )

String

char ( int char )

Variant

convert ( Variant what, int type )

Object

dict_to_inst ( Dictionary dictionary )

Array

get_stack ( )

Dictionary

inst_to_dict ( Object instance )

bool

is_instance_of ( Variant value, Variant type )

int

len ( Variant var )

Resource

load ( String path )

Resource

preload ( String path )

void

print_debug ( ... ) vararg

void

print_stack ( )

Array

range ( ... ) vararg

bool

type_exists ( StringName type )


Constants

PI = 3.14159265358979

Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to TAU / 2, or 180 degrees in rotations.

TAU = 6.28318530717959

The circle constant, the circumference of the unit circle in radians. This is equivalent to PI * 2, or 360 degrees in rotations.

INF = inf

Positive floating-point infinity. This is the result of floating-point division when the divisor is 0.0. For negative infinity, use -INF. Dividing by -0.0 will result in negative infinity if the numerator is positive, so dividing by 0.0 is not the same as dividing by -0.0 (despite 0.0 == -0.0 returning true).

Warning: Numeric infinity is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer number by 0 will not result in INF and will result in a run-time error instead.

NAN = nan

"Not a Number", an invalid floating-point value. NAN has special properties, including that != always returns true, while other comparison operators always return false. This is true even when comparing with itself (NAN == NAN returns false and NAN != NAN returns true). It is returned by some invalid operations, such as dividing floating-point 0.0 by 0.0.

Warning: "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer 0 by 0 will not result in NAN and will result in a run-time error instead.


Annotations

@export ( )

Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property, use the type hint notation.

@export var string = ""
@export var int_number = 5
@export var float_number: float = 5
@export var image: Image

@export_category ( String name )

Define a new category for the following exported properties. This helps to organize properties in the Inspector dock.

See also @GlobalScope.PROPERTY_USAGE_CATEGORY.

@export_category("Statistics")
@export var hp = 30
@export var speed = 1.25

Note: Categories in the Inspector dock's list usually divide properties coming from different classes (Node, Node2D, Sprite, etc.). For better clarity, it's recommended to use @export_group and @export_subgroup, instead.


@export_color_no_alpha ( )

Export a Color property without allowing its transparency (Color.a) to be edited.

See also @GlobalScope.PROPERTY_HINT_COLOR_NO_ALPHA.

@export_color_no_alpha var dye_color: Color

@export_dir ( )

Export a String property as a path to a directory. The path will be limited to the project folder and its subfolders. See