Godot Snippets

Just a collection of little things that can make your life in Godot easier.

@tool notation

With the @tool notation you can make scripts executable in the editor

Create your own hints for export vars

## -1 for all
@export var my_export_var:String

With this the “-1 for all” will be shown when the mouse hovers over the variable in the inspector.

Create your own signals

You can create your own signals in your scripts to trigger stuff in your game.

These are then also visible in the side menü (where the others signals are located)

Global Classes for your game

You can set up classes that are loaded by the game engine and globally accessable in all scripts you use. To do so add the class you want to be autoloaded and global in die Project-Settings->Autoload.

You than can access the class via the name you have given it in the autload setup

Use enums for selections in export vars

When you use an enum for selection you won’t have to remember ids or exact strings

@export_enum["first", "second", "third"] var test:String

to save the string itself, or

@export_enum["first", "second", "third"] var test:int

to save the integer of the position inside the enum