Variables

Variables are Resources that hold a typed value and emit a signal when the value changes.
Available variable types (scripts live under addons/godot_meds_core/scripts/variables/):
BoolVariableIntVariableFloatVariableStringVariableColorVariableVector2VariableVector3Variable
Common API (implemented via BaseVariable):
valueproperty (typed per variable)value_changed(new_value)signalinitial_valueexported propertydebug_logsexported bool: when enabled, logs value changes + a stack trace + which listeners are connectedsave_to_deviceexported bool: persists changes touser://settings.cfgand reloads on startup- stored in section
variables - key is the variable’s
resource_path.get_basename()
- stored in section
Creating a variable resource
- In the FileSystem dock: Right click → New Resource…
- Pick e.g.
BoolVariableand save it as a.tres. - Assign that
.tresto exported fields in scripts.
Using variables in scripts
extends Node
@export var bool_variable: BoolVariable
func _ready() -> void:
bool_variable.value_changed.connect(_on_bool_changed)
print("Initial value:", bool_variable.value)
func _on_bool_changed(new_value: bool) -> void:
print("Bool changed to:", new_value)
When you want better debug output that includes the caller, prefer the typed helper method:
bool_variable.set_value(true, self)