SproutyDialogsVariableManager
Inherits: Node
Description
This class manages the variables in the Sprouty Dialogs plugin. It provides methods to get, set, check, parse variables in strings and get assigment and comparision operations results.
This manager is used at runtime as an internal singleton to handle variables. You shouldn't instantiate this class directly. Instead, access the singleton through the Sprouty Dialogs autoload.
Methods
| Return Type | Method |
|---|---|
| void | get_variables_data() |
| Dictionary | get_variable_data(name: String) |
| Variant | get_variable(name: String) |
| void | set_variable(name: String, value: Variant) |
| bool | has_variable(name: String) |
| Array | get_variables_in_group(group_name: String) |
| bool | is_variable_in_group(variable_name: String, group_name: String) |
| void | reset_variable(name: String = "") |
| String | parse_variables(text: String, ignore_error: bool = false) |
| Variant | get_assignment_result(type: int, operator: int, value: Variant, new_value: Variant) |
| Variant | get_comparision_result(first_var: Dictionary, second_var: Dictionary, operator: int) |
Method Descriptions
func get_variables_data() -> Dictionary
Returns all the variables data as a dictionary. If the variables are not loaded, it will load them from project settings.
func get_variable_data(name: String) -> Dictionary
Get the data of a variable defined in the variable editor or from the autoloads. If the variable is found, it returns a dictionary with its data. If the variable does not exist, it returns an empty dictionary.
func get_variable(name: String) -> Variant
Get the value of a variable defined in the variable editor or from the autoloads. If the variable is found, it returns a dictionary with its data. If the variable does not exist, it returns null.
func set_variable(name: String, value: Variant) -> void
Set or update the value of a variable defined in the variable editor or from the autoloads.
func has_variable(name: String) -> bool
Check if a variable exists in the variable editor or in the autoloads.
func get_variables_in_group(group_name: String) -> Array
Retuns a list with the names of the variables in a group. If no group is especified, return the top-level variables.
func is_variable_in_group(variable_name: String, group_name: String) -> bool
Check if a variable is in a given group.
func reset_variable(name: String = "") -> void
Reset a variable to its initial value. If no variable is specified, reset all variables. This method only resets variables defined in the variable editor, you cannot reset variables from autoloads here.
func parse_variables(text: String, ignore_error: bool = false) -> String
Replaces all variables ({}) in a text with their corresponding values.
func get_assignment_result(type: int, operator: int, value: Variant, new_value: Variant) -> Variant
Returns the value resulting from an assignment operation.
func get_comparison_result(first_var: Dictionary, second_var: Dictionary, operator: int) -> Variant
Returns the result of comparing two values based on the specified operator.