Show Menu
Cheatography

GDScript Cheat Sheet (DRAFT) by

GDScript is a high-level, both static and dynamically typed programming language specifically designed for the Godot game engine.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Declare variables

var my_var­iable = 10
Declare a variable
my_var­iable = 20
Change the value of a variable
var my_int: int = 5
Declare a variable with a specific type
static var my_sta­tic­_va­riable = 30
Declare a static variable
my_sta­tic­_va­riable = 40
Change the value of a static variable
MyClas­s.m­y_s­tat­ic_­var­iable = 40
Since statics belong to the class, you can also use them
const MY_CON­STANT = 100
Declare a constant

Comments

"""
This is a multiline string, not a comment!
And thus it will be parsed by interpreter...
"""

# Now this
# is a multiline comments
# Interpreter will not read this

Variable Types

var x: int = 42
int: Integer numbers
var y: float = 3.14
float: Floati­ng-­point numbers
var is_active: bool = true
bool: Boolean values (true or false)
var name: String = "­lol­lyg­ag"
String: Text strings
var my_array: Array = [1, 2, 3, 4, 5]
Array: Ordered list of elements
var my_dict: Dictionary = {"ke­y1": "­val­ue1­", "­key­2": "­val­ue2­"}
Dictio­nary: Key-value pairs