mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
b55a462945
After months of work and over a hundred commits on this repo alone (not to mention the old, half-working repos on GitHub), StreamGraph is finally ready to be shown to the public, even if in an incomplete state. This PR is a culmination of numerous design discussions, re-writes, and hours spent by both @Eroax and myself. Reviewed-on: https://codeberg.org/Eroax/StreamGraph/pulls/18 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
54 lines
1.1 KiB
GDScript
54 lines
1.1 KiB
GDScript
# (c) 2023-present Eroax
|
|
# (c) 2023-present Yagich
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
extends DeckNode
|
|
|
|
var times_activated := 0
|
|
|
|
|
|
func _init() -> void:
|
|
name = "Print"
|
|
node_type = name.to_snake_case()
|
|
description = "Print a value to the console."
|
|
|
|
props_to_serialize = [&"times_activated"]
|
|
category = "general"
|
|
|
|
add_input_port(
|
|
DeckType.Types.ANY,
|
|
"Data 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 = str(resolve_input_port_value(0))
|
|
if data_to_print == null:
|
|
data_to_print = str(data)
|
|
if (data_to_print as String).is_empty():
|
|
data_to_print = "<nothing>"
|
|
|
|
times_activated += 1
|
|
|
|
# var data_to_print = input_ports[0].value_callback.call()
|
|
#print(data_to_print)
|
|
#print("extra data: ", extra_data)
|
|
DeckHolder.logger.log_node(data_to_print)
|
|
if !extra_data.is_empty():
|
|
DeckHolder.logger.log_node(str("Extra data: ", extra_data))
|
|
send(0, true)
|