miggor-StreamGraph/classes/deck/nodes/print.gd
Lera Elvoé c4e35043df types system simplification (#8)
no longer using classes for every type. the type system has been greatly simplified, with the added bonus that it hooks directly into GraphEdit's slot type system. connections will still fail if the type conversion fails, which may be used by other renderers.

the type conversion map is straightforward to understand, and easy to extend should the need arise (hopefully it shouldn't).

Reviewed-on: https://codeberg.org/Eroax/Re-DotDeck/pulls/8
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
2023-11-26 22:07:15 +00:00

50 lines
984 B
GDScript

extends DeckNode
var times_activated := 0
func _init() -> void:
name = "Print"
node_type = name.to_snake_case()
description = "print a value"
props_to_serialize = [&"times_activated"]
category = "general"
add_input_port(
DeckType.Types.STRING,
"Text to print",
"field"
)
add_input_port(
DeckType.Types.BOOL,
"Trigger",
"button"
)
add_output_port(
DeckType.Types.BOOL,
"On Trigger",
"label"
)
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
if to_input_port != 1:
return
var data_to_print
if request_value(0) != null:
data_to_print = request_value(0)
elif get_input_ports()[0].value_callback.get_object() && get_input_ports()[0].value_callback.call() != "":
data_to_print = get_input_ports()[0].value_callback.call()
else:
data_to_print = data
times_activated += 1
# var data_to_print = input_ports[0].value_callback.call()
print(data_to_print)
print("extra data: ", extra_data)
send(0, true)