Skip to reading
GDScript Programming & Godot

32. Save state, instance state and project settings

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
Code example
var visit_counter: int = 0
Code example
func run() -> int:
    visit_counter += 1
    Log("Calls this session: " + str(visit_counter))
    Variable.powered.value = true
    return visit_counter
Source table from 32. Save state, instance state and project settings, page 41
StoreLifetime / purpose
Local variableOne function call
Member on ordinary native recordOne temporary script instance/call
Member on global native recordCurrent session until reload, invalidation or shutdown
Variable registry / game variablesGame state managed by PCA save/load
Included-variable storeRouter-owned shared session/cache state
user:// custom fileYour explicit persistence format
Runtime project/record dataConfiguration and live state; persistence depends on the specific route

GetSetting/SetSetting and GetProjectProperty/SetProjectProperty address the running project. They do not save the editor document to disk. For a live feature with a dedicated action, use that action when immediate reconfiguration matters.

Page 41 of 378Permalink
Go to page