These are the list of keyboards supported by the language. Keywords are reserved words (tokens), they cannot be used as identifiers. Operators (like in, not, and, or) and names of built-in types, as listed in the following sections, are also reserved.
The keyboard is defined in the GDScript tokenizer which are given below:
The following is the list of supported operators and its precedence.
Anything from a #(hash) to the end of the line is ignored and considered as a comment.
Multi-line comments can be created using """ (three quotes in a row) at the beginning and end of a block of text. Note that this creates a string; therefore, it will not be stripped away when the script is compiled.
Built-in types are stack-allocated, and they are passed as values. This means a copy is created on each assignment or when it was moving them as arguments to functions. The only exceptions are Array and Dictionaries, which are given by reference, so they are shared. (Not PoolArray like PoolByteArray though, those are passed as values too, so consider this when deciding which to use!)
Basic built-in types
A variable in GDScript can be assigned to several built-in types.
It is an empty data type that contains no information and cannot be assigned any other value.
The Boolean data type only contains true or false.
This data type can contain only integer numbers (both negative and positive).
It is used to provide a floating-point value (real numbers).
A sequence of characters in Unicode format. Strings can contain the standard C escape sequences. GDScript supports format strings printf functionality.
Vector built-in types
2D vector type containing x and y fields. It can also be accessed as an array.
2D vector type containing two vectors fields: position and size. Alternatively contains an end field, which is position+size.
3D vector type containing x, y, and z fields. This can also be accessed as an array.
In 2D, transforms 3x2 matrix is used.
3D plane type in the normalized form that contains a standard vector field and a d scalar distance.
Quaternion is a data type used for representing a 3D rotation. It is useful for interpolating rotations.
The axis-aligned bounding box (or 3D box) contains two vectors fields: position and size. Alternatively contains an end field, which is positive + size.
3x3 matrix used for 3D rotation and scale. It contains three vector fields (x, y, and z) and can also be accessed as an array of 3D vectors.
3D transform contains a basis field basis and a Vector3 field origin.
Engine build-in types
The data type contains r, g, b, and fields. It can also be accessed as h, s, and v for hue/saturation/value.
Compiled path to a node used mainly in the scene system. It can be easily assigned to and from a string.
Resource ID (RID). Servers use generic RIDs to reference opaque data.
Base class for anything that is not a built-in type.
Container built-in types
Arrays are indexed starting form index 0. Starting with Godot 2.1, indices may be negative like in python, to count from the end. Generic sequence of arbitrary objects types, including other arrays or dictionaries. The array can resize dynamically.
GDScript arrays are allotted linearly in memory for speed. Large arrays, which are more than tens of thousands of elements) may, however, cause memory fragmentation. If it is a concern, particular types of arrays are available. These only accept a single data type. They avoid memory fragmentation and also use less memory but are atomic and tend to run slower than generic arrays. They are recommended to use for large data sets.
Associative container which contains values referenced by unique keys.
Lua-style table syntax is also supported. Lua-style uses = instead of: and does not use quotes to mark string keys (making for slightly less to write).Keys are written in this form cannot start with a digit.
To add a key to an existing dictionary, access it like an existing key and assign to it:
Variables can exist as class members or local to functions. They are created with the var keyboard and may, optionally, be assigned a value upon initialization.
Constants are similar to the variables, but must be constants or constant expressions and must be assigned on initialization.
Enums are a shorthand for constants and are pretty useful if we want to assign consecutive integers to some constant.
If we pass a name to the enum, it also put all the values inside a constant dictionary of the name.
Functions belong to a class always. The scope priority for variable look-up: local-class member-global. The self-variable is always available and is provided as an option for accessing class members, but is not always required (and cannot be sent as the function's first argument, unlike python).
It can return at any point. The default return value is null.