miggor-StreamGraph/classes/deck/nodes/print.gd

51 lines
996 B
GDScript3
Raw Normal View History

extends DeckNode
2023-07-21 10:10:24 +02:00
var times_activated := 0
func _init() -> void:
2023-07-21 07:30:12 +02:00
name = "Print"
node_type = name.to_snake_case()
description = "print a value"
2023-07-21 10:10:24 +02:00
props_to_serialize = [&"times_activated"]
category = "general"
2023-07-21 10:10:24 +02:00
add_input_port(
DeckType.Types.ANY,
"Data to print",
"field"
)
2023-06-10 20:23:57 +02:00
add_input_port(
DeckType.Types.BOOL,
2023-06-10 20:23:57 +02:00
"Trigger",
"button"
)
2023-06-12 17:32:16 +02:00
add_output_port(
DeckType.Types.BOOL,
2023-06-12 17:32:16 +02:00
"On Trigger",
"label"
)
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
if to_input_port != 1:
2023-06-10 20:23:57 +02:00
return
var data_to_print
if request_value(0) != null:
data_to_print = str(request_value(0))
elif get_input_ports()[0].value_callback.get_object() && get_input_ports()[0].value_callback.call() != "":
data_to_print = str(get_input_ports()[0].value_callback.call())
else:
data_to_print = str(data)
2023-07-21 10:10:24 +02:00
times_activated += 1
2023-06-11 17:39:26 +02:00
# var data_to_print = input_ports[0].value_callback.call()
print(data_to_print)
print("extra data: ", extra_data)
send(0, true)