Skip to content

LocalVariables ​

Inherits: Resource

Resource for storing local variables dictionary for Events Provides methods for managing event-specific variables

Properties ​

Dictionaryvariables{}
Dictionarymetadata{}

Methods ​

Variantget_variable( key: String, default_value: Variant = null )
voidset_variable( key: String, value: Variant )
boolhas_variable( key: String )
boolremove_variable( key: String )
Arrayget_variable_keys()
intget_variable_count()
voidclear_variables()
voidupdate_metadata()
voidset_variables_from_dict( new_variables: Dictionary )
voidset_parent_event_id( event_id: int )
intget_parent_event_id()
boolis_valid_key( key: String )
Stringget_key_suggestions( key: String )
Array[Dictionary]validate_variables()
voidincrement_variable( key: String, amount: float = 1.0 )
voiddecrement_variable( key: String, amount: float = 1.0 )
voidmultiply_variable( key: String, multiplier: float )
voidtoggle_variable( key: String )
voidappend_to_variable( key: String, text: String )
voidadd_to_array_variable( key: String, item: Variant )
boolremove_from_array_variable( key: String, item: Variant )
boolarray_variable_contains( key: String, item: Variant )
voidmerge_variables( other: LocalVariables, overwrite: bool = false )
voidcopy_variables_to( target: LocalVariables, overwrite: bool = false )
Dictionarycreate_snapshot()
boolrestore_from_snapshot( snapshot: Dictionary )
Dictionaryto_dict()
voidfrom_dict( data: Dictionary )
Array[Dictionary]get_variables_for_editor()
Dictionaryexport_variables()
boolimport_variables( data: Dictionary, merge_mode: bool = false )
Stringget_variables_debug_string()
Dictionaryget_debug_info()
Dictionaryestimate_memory_usage()

Property descriptions ​

Dictionary variables = ​

The variables, by name.

Dictionary metadata = ​

Extra data about the variables.

Method descriptions ​

Variant get_variable( key: String, default_value: Variant = null ) ​

Get a variable value with optional default

void set_variable( key: String, value: Variant ) ​

Set a variable value

bool has_variable( key: String ) ​

Check if variable exists

bool remove_variable( key: String ) ​

Remove a variable

Array get_variable_keys() ​

Get all variable keys

int get_variable_count() ​

Get variable count

void clear_variables() ​

Clear all variables

void update_metadata() ​

Update metadata

void set_variables_from_dict( new_variables: Dictionary ) ​

Set variables from dictionary

void set_parent_event_id( event_id: int ) ​

Set parent event ID for reference

int get_parent_event_id() ​

Get parent event ID

bool is_valid_key( key: String ) ​

Validate variable key (checks for common issues)

String get_key_suggestions( key: String ) ​

Get suggestions for fixing invalid keys

Array[Dictionary] validate_variables() ​

Validate all variables

void increment_variable( key: String, amount: float = 1.0 ) ​

Increment a numeric variable (creates with value 1 if doesn't exist)

void decrement_variable( key: String, amount: float = 1.0 ) ​

Decrement a numeric variable

void multiply_variable( key: String, multiplier: float ) ​

Multiply a numeric variable

void toggle_variable( key: String ) ​

Toggle a boolean variable (creates with true if doesn't exist)

void append_to_variable( key: String, text: String ) ​

Append to a string variable (creates empty string if doesn't exist)

void add_to_array_variable( key: String, item: Variant ) ​

Add item to array variable (creates empty array if doesn't exist)

bool remove_from_array_variable( key: String, item: Variant ) ​

Remove item from array variable

bool array_variable_contains( key: String, item: Variant ) ​

Check if array variable contains item

void merge_variables( other: LocalVariables, overwrite: bool = false ) ​

Merge variables from another LocalVariables instance

void copy_variables_to( target: LocalVariables, overwrite: bool = false ) ​

Copy variables to another LocalVariables instance

Dictionary create_snapshot() ​

Create a snapshot of current variables

bool restore_from_snapshot( snapshot: Dictionary ) ​

Restore from a snapshot

Dictionary to_dict() ​

Serialize to dictionary for save/load

void from_dict( data: Dictionary ) ​

Deserialize from dictionary for save/load

Array[Dictionary] get_variables_for_editor() ​

Get variables formatted for editor display

Dictionary export_variables() ​

Export variables to dictionary for external use

bool import_variables( data: Dictionary, merge_mode: bool = false ) ​

Import variables from dictionary

String get_variables_debug_string() ​

Get variables as formatted string for debugging

Dictionary get_debug_info() ​

Get comprehensive info about this LocalVariables instance

Dictionary estimate_memory_usage() ​

Estimate memory usage of variables