fix connections

This commit is contained in:
Lera Elvoé 2023-06-11 18:39:11 +03:00
parent 6b43e807d6
commit badd1e2450
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View file

@ -22,7 +22,6 @@ static var type_assoc: Dictionary = {
} }
func add_node(node: GDScript, meta: Dictionary = {}) -> DeckNode: func add_node(node: GDScript, meta: Dictionary = {}) -> DeckNode:
# TODO: accept instances of DeckNode instead of instancing here? # TODO: accept instances of DeckNode instead of instancing here?
var uuid := UUID.v4() var uuid := UUID.v4()
@ -44,9 +43,9 @@ func get_node(uuid: String) -> DeckNode:
func connect_nodes(from_node: DeckNode, to_node: DeckNode, from_port: int, to_port: int) -> bool: func connect_nodes(from_node: DeckNode, to_node: DeckNode, from_port: int, to_port: int) -> bool:
# first, check that we can do the type conversion. # first, check that we can do the type conversion.
var type_a: Types = from_node.input_ports[from_port].type var type_a: Types = from_node.output_ports[from_port].type
var type_b: Types = to_node.output_ports[to_port].type var type_b: Types = to_node.input_ports[to_port].type
var err: DeckType = (type_assoc[type_b] as GDScript).from(type_assoc[type_a]) var err: DeckType = (type_assoc[type_b]).from(type_assoc[type_a].new())
if err is DeckType.DeckTypeError: if err is DeckType.DeckTypeError:
print(err.error_message) print(err.error_message)
return false return false

View file

@ -20,7 +20,7 @@ func add_output_port(type: Deck.Types, label: String, descriptor: String = "") -
func send(from_port: int, data: DeckType, extra_data: Array = []) -> void: func send(from_port: int, data: DeckType, extra_data: Array = []) -> void:
if !(outgoing_connections.get(from_port)): if outgoing_connections.get(from_port) == null:
return return
for connection in outgoing_connections[from_port]: for connection in outgoing_connections[from_port]: