LocalVariables ​
Inherits: Resource
Resource for storing local variables dictionary for Events Provides methods for managing event-specific variables
Properties ​
Dictionary | variables | {} |
Dictionary | metadata | {} |
Methods ​
Variant | get_variable( key: String, default_value: Variant = null ) |
void | set_variable( key: String, value: Variant ) |
bool | has_variable( key: String ) |
bool | remove_variable( key: String ) |
Array | get_variable_keys() |
int | get_variable_count() |
void | clear_variables() |
void | update_metadata() |
void | set_variables_from_dict( new_variables: Dictionary ) |
void | set_parent_event_id( event_id: int ) |
int | get_parent_event_id() |
bool | is_valid_key( key: String ) |
String | get_key_suggestions( key: String ) |
Array[Dictionary] | validate_variables() |
void | increment_variable( key: String, amount: float = 1.0 ) |
void | decrement_variable( key: String, amount: float = 1.0 ) |
void | multiply_variable( key: String, multiplier: float ) |
void | toggle_variable( key: String ) |
void | append_to_variable( key: String, text: String ) |
void | add_to_array_variable( key: String, item: Variant ) |
bool | remove_from_array_variable( key: String, item: Variant ) |
bool | array_variable_contains( key: String, item: Variant ) |
void | merge_variables( other: LocalVariables, overwrite: bool = false ) |
void | copy_variables_to( target: LocalVariables, overwrite: bool = false ) |
Dictionary | create_snapshot() |
bool | restore_from_snapshot( snapshot: Dictionary ) |
Dictionary | to_dict() |
void | from_dict( data: Dictionary ) |
Array[Dictionary] | get_variables_for_editor() |
Dictionary | export_variables() |
bool | import_variables( data: Dictionary, merge_mode: bool = false ) |
String | get_variables_debug_string() |
Dictionary | get_debug_info() |
Dictionary | estimate_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