# Guide to the Godot game engine/Programming/GDScript/Data types

Guide to the Godot game engine
<-- If conditions Data types Manipulating the SceneTree-->
Skip to bottom

## null

Null is the absence of value. Null can be inferred as a function's return value with -> void.
Never evaluates as true in if statements:
This is the default value used in a variable if it has not been set. If a function that you made is supposed to returns something, but instead return null, be sure to check the output for errors, and double check the function is working properly.

## bool

A bool is a basic data type which may only have 2 values: true (positive, on or 1) and false (negative, off or 0). bool may be inferred as a function's return value with -> bool.
bools evaluate as true in an if statements if it is equal to true:
If converted to an integer (with int(bool)), it becomes 0 if it's false and 1 if true.

#### History

Bools were invented by George Boole. George was an English mathematician whose work is the result of a special programming system. This system may only have 2 values, true and false. It was called "Boolean logic" in his honor.
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_bool.html

## int

An int, or integer, is a whole number. int may be inferred as a function's return value with -> int.
ints evaluate as true in an if statements if not equal to 0:

#### Operators

Ints are great for maths. They support the following operators:
Comparitive:
Modifiers (use a number on both sides):
Useful constants:
Speaking of NaN, NaN is not equal to NaN (NAN == NAN is never true). Instead, use is_nan(variable) to see if it is NaN.
To check for infinity (INF is equal to INF, but INF is not equal to -INF), use is_inf(variable).
Ints can be separated with underscores, like 36_234_785 (which makes 36234785) to be easier to read.

#### See also

Float, decimal numbers
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_int.html

## float

Floats, also known as floating-point numbers, are decimal numbers, like 1.7. float may be inferred as a function's return value with -> float.
floats evaluate as true in an if statements if not equal to 0.0:

#### Operators

Floats are great for maths. They support the following operators:
Comparative:
Modifiers (use a number on both sides):
Useful constants:
To check if two numbers are approximately equal (I.e: less than 0.00001 difference), use is_equal_approx(num1, num2).
Floats can be separated with underscores to be easier to read, like ints.

#### See also

Integers, whole numbers
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_float.html

## String

A versatile data type that can be any length. They are a string of characters. Hence the name "String". String may be inferred as a function's return value with -> String.
Strings evaluate as true in an if statements if not empty:
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_string.html

## Array

An array is even more versatile than a String. It may be any length, and each value has a numerical index (of int). An Array may be inferred as a function's return value with -> Array.
In an if statement Arrays evaluate as false when empty:
Arrays are passed by reference rather than value. See Dictionary.
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_array.html]

## Dictionary

Dictionarys are the most versatile data type in Godot, besides Objects themselves. Dictionary may be inferred as a function's return value with -> Dictionary.
Dictionarys evaluate as true in an if statements if not empty:
Every value is indexed with a value. You can use any data type or Object you wish. As the value or key. FuncRefs and Nodes also count, but remember to keep that same FuncRef or Node (instead of using a different FuncRef for the same function). Even another Dictionary or Array can be used as a key or value.
Dictionaries are passed as reference rather than value, meaning this is never true:
Although this is:
This can be useful by saving the same Dictionary in multiple variables, then changing one of them changes them all. If you don't want this functionality, use dictionary.duplicate(true).
To compare them, use hash:

#### Indexing

To get a value from a dictionary, you need to retrieve it with its index.
So "Bob" has no points. So the label says "Score: 0".
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_dictionary.html

## Vector2

A vector is a value with multiple floats. Vector2 is used for 2D positioning among other things. They are indexed at the end with:
* ".x" or "[0]"
* ".y" or "[1]"
They are complex things, including many functions. Vector2 may be inferred as a function's return value with ->Vector2.
Vector2s evaluate as true in an if statements if at least one value is not equal to 0:
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_vector2.html

## Vector3

A vector is a value with multiple floats. A Vector3 has 3 numbers and used for 3D positional and rotational data, among other things. They are indexed at the end with:
* ".x" or "[0]"
* ".y" or "[1]"
* ".z" or "[2]"
Vector3s are complex things, having many functions. Vector3 may be inferred as a function's return value with ->Vector3.
Vector3s evaluate as true in an if statements if at least one value is not equal to 0:
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_vector3.html

## Color

Technically considered a vector, it contains 4 values:
* ".r" - the red channel (E.g: 0 is no red, 1 is full red)
* ".g"- the green channel
* ".b" - the blue channel
* ".a" - alpha (or transparency)
Color may be inferred as a function's return value with ->Color.
Colors evaluate as true in an "if" statements if not black with no transparency (Color(0, 0, 0, 1) is false):
If r, g and b are 1, the color is white. If they are 0, the color is black. Know your color wheel! No color or all the colors!
Now, this can be irritating sometimes. How do you quickly get basic colors like orange and yellow? Or common shades of red, green and blue? Color.orange is a simple way to do so.
All color constants:
| aliceblue | antiquewhite | aqua | aquamarine |
| azure | beige | bisque | black |
| blanchedalmond | blue | blueviolet | brown |
| burlywood | cadetblue | chartreuse | chocolate |
| coral | cornflower | cornsilk | crimson |
| cyan | darkblue | darkcyan | darkgoldenrod |
| darkgray | darkgreen | darkkhaki | darkmagenta |
| darkolivegreen | darkorange | darkorchid | darkred |
| darksalmon | darkseagreen | darkslateblue | darkslategray |
| darkturquoise | darkviolet | deeppink | deepskyblue |
| dodgerblue | firebrick | florawhite | forestgreen |
| fuchsia | gainsborow | ghostwhite | gold |
| goldenrod | gray | green | greenyellow |
| honeydew | hotpink | indianred | indigo |
| ivory | khaki | lavender | lavenderblush |
| lawngreen | lemonchiffon | lightblue | lightcoral |
| lightcyan | lightgoldenrod | lightgray | lightgreen |
| lightpink | lightsalmon | lightseagreen | lightskyblue |
| lightslategray | lightsteelblue | lightyellow | lime |
| limegreen | linen | magenta | maroon |
| mediumaquamarine | mediumblue | mediumorchid | mediumpurple |
| mediumseagreen | mediumslateblue | mediumspringgreen | mediumturquoise |
| mediumvioletred | midnightblue | mintcream | mistyrose |
| moccasin | navajowhite | navyblue | oldlace |
| olive | olivedrab | orange | orangered |
| orchid | palegoldenrod | palegreen | paleturquoise |
| palevioletred | papayawhip | peachpuff | peru |
| pink | plum | powderblue | purple |
| rebeccapurple | red | rosybrown | royalblue |
| saddlebrown | salmon | sandybrown | seagreen |
| seashell | sienna | silver | skyblue |
| slateblue | slategray | snow | springgreen |
| steelblue | tan | teal | thistle |
| tomato | transparent | turquoise | violet |
| webgray | webgreen | webmaroon | webpurple |
| wheat | white | whitesmoke | yellow |
| yellowgreen | dimgray |
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_color.html

## Basis

A Basis contains a 3x3 matrix for 3D position, rotation and scale of 3D objects. Basis may be inferred as a function's return value with ->Basis.
Basiss evaluate as true in an if statements if at least one of its Vector3s would also evaluate as true:

#### See also

Matrices and transforms tutorial.
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_basis.html

## Transform2D

A Transform2D is a 2x3 matrix used for 2D linear transformations. It can represent transformations such as translation, rotation or scaling. It consists of three Vector2 values: x, y and origin. Transform2D may be inferred as a function's return value with ->Transform2D.
Transform2Ds evaluate as true in an if statements if at least one value is not 0:
See more: The matrices and transforms tutorial.
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_transform2d.html

## Transform

A Transform is a 3x4 matrix used for 3D linear transformations. It can represent transformations such as translation, rotation or scaling. It consists of a Basis (first 3 Vector3s) and origin (last value). Transform may be inferred as a function's return value with ->Transform.
Transforms evaluate as true in an if statements if at least one value is not 0:
See more: The matrices and transforms tutorial and the using Transforms tutorial.
See the official documentation for more: https://docs.godotengine.org/en/stable/classes/class_transform.html

## Pool<type>Array

For detailed information, please see Array. PoolArrays are optimized versions of Array, but allow storing only one variant type. They also don't contain certain functions, like find.
PoolArrays are passed as value rather than reference:
As you can see, the PoolStringArray does not keep the same values across all references, but the Array does.
Allowed types for Pool<type>Arrays are: int, float, string, real (bytes), color, vector2, and vector3. They may only store data types that match the type mentioned in the name, and are more optimized in terms of memory.
GDScript
* Global scope
* Keywords
* If statements
* If conditions
* Data types
* Manipulate the SceneTree
* Making nodes
* Tips and Tricks