add interface for setting variables in deck

This commit is contained in:
Lera Elvoé 2024-01-17 09:31:03 +03:00
parent 1992d840d9
commit 03300438c1
No known key found for this signature in database
2 changed files with 10 additions and 1 deletions

View file

@ -44,6 +44,8 @@ signal node_added(node: DeckNode)
signal node_removed(node: DeckNode) signal node_removed(node: DeckNode)
## Emitted when nodes have been disconnected ## Emitted when nodes have been disconnected
signal nodes_disconnected(from_node_id: String, to_node_id: String, from_output_port: int, to_input_port: int) signal nodes_disconnected(from_node_id: String, to_node_id: String, from_output_port: int, to_input_port: int)
## Emitted when the [member variable_stack] has been modified.
signal variables_updated()
#region group signals #region group signals
signal node_added_to_group(node: DeckNode, assign_id: String, assign_to_self: bool, deck: Deck) signal node_added_to_group(node: DeckNode, assign_id: String, assign_to_self: bool, deck: Deck)
@ -196,6 +198,12 @@ func remove_node(uuid: String, remove_connections: bool = false, force: bool = f
node_removed_from_group.emit(uuid, remove_connections, self) node_removed_from_group.emit(uuid, remove_connections, self)
## Set a variable on this deck.
func set_variable(var_name: String, value: Variant) -> void:
variable_stack[var_name] = value
variables_updated.emit()
## Group the [param nodes_to_group] into a new deck and return it. ## Group the [param nodes_to_group] into a new deck and return it.
## Returns [code]null[/code] on failure.[br] ## Returns [code]null[/code] on failure.[br]
## Adds a group node to this deck, and adds group input and output nodes in the group. ## Adds a group node to this deck, and adds group input and output nodes in the group.

View file

@ -42,7 +42,8 @@ func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> vo
var var_name: String = resolve_input_port_value(0) var var_name: String = resolve_input_port_value(0)
var var_value: Variant = resolve_input_port_value(1) var var_value: Variant = resolve_input_port_value(1)
_belonging_to.variable_stack[var_name] = var_value #_belonging_to.variable_stack[var_name] = var_value
_belonging_to.set_variable(var_name, var_value)
send(0, var_value) send(0, var_value)