Skip to content

Global Variables ​

A global variable is a named value that the whole game shares and that is saved with the game: king_dead, bandits_killed, reputation_with_miller, chosen_path. Events set them, conditions test them, and quests and conversations can react to them. They are how one part of the story tells another part what happened.

Events > Global Variables lists them, with their starting values.

The editor ​

ControlWhat it does
AddMakes a variable: type its key and choose its type
Edit (double click, or right-click)Changes the starting value
Duplicate, DeleteAs they say

Each line shows key = value (type).

TypeHoldsExample
IntA whole numberbandits_killed = 0
FloatA number with decimalsreputation = 12.5
BoolTrue or falseking_dead = false
StringTextchosen_path = "north"
Array, DictionaryA list, a set of named valuesEdited in Godot's inspector (the editor says so)

The key is the name you use everywhere; keep it short and without spaces (king_dead). A key must be unique.

Using them ​

WhereHow
ActionsSet Global Variable sets a value. Modify Global Variable changes it: add, subtract, multiply or divide a number, append to text, or toggle a bool
ConditionsGlobal Variable is true when the variable compares the way you say with a value (equal, more than, less than...). The comparison fits the type
TriggersGlobal Variable fires on any change, when the variable reaches a value, when it leaves a value, or when it crosses a number going up or down
CodeEventManager holds them; see How events are built

The starting value and the saved value ​

What you edit here is the starting value: a new game begins with it. While the game runs, the changes are made to a working copy and saved with the game; the file in the project is never changed. A new game starts from the starting values again. The type is saved with the value, so an int stays an int after a save and load.

Event local variables ​

Variables that belong to a single event, and are not shared, are the local variables of the event.

See also ​