2023-12-15 22:44:25 +01:00
|
|
|
# (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)
|
2023-06-10 19:13:16 +02:00
|
|
|
extends DeckNode
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
2023-07-21 07:30:12 +02:00
|
|
|
name = "Print"
|
|
|
|
node_type = name.to_snake_case()
|
2023-12-15 22:44:25 +01:00
|
|
|
description = "Print a value to the console."
|
2023-07-21 07:30:12 +02:00
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
add_input_port(
|
2023-12-15 22:44:25 +01:00
|
|
|
DeckType.Types.ANY,
|
|
|
|
"Data to print",
|
2023-06-10 19:13:16 +02:00
|
|
|
"field"
|
|
|
|
)
|
|
|
|
|
2023-06-10 20:23:57 +02:00
|
|
|
add_input_port(
|
2024-03-06 08:50:23 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-06-10 20:23:57 +02:00
|
|
|
"Trigger",
|
2024-03-06 08:50:23 +01:00
|
|
|
"button",
|
|
|
|
Port.UsageType.TRIGGER,
|
|
|
|
).button_pressed.connect(_receive.bind(1, null))
|
2023-06-12 17:32:16 +02:00
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
|
2024-02-22 08:23:25 +01:00
|
|
|
func _receive(to_input_port: int, data: Variant) -> void:
|
2024-04-11 16:56:33 +02:00
|
|
|
print(_belonging_to.get_reference_count())
|
2024-03-06 08:50:23 +01:00
|
|
|
var data_to_print := ""
|
|
|
|
if to_input_port == 1:
|
|
|
|
data = await resolve_input_port_value_async(0)
|
2023-06-10 20:23:57 +02:00
|
|
|
|
2024-03-06 08:50:23 +01:00
|
|
|
if data == null:
|
|
|
|
data_to_print = "<nothing>"
|
|
|
|
else:
|
2023-12-15 22:44:25 +01:00
|
|
|
data_to_print = str(data)
|
2024-03-06 08:50:23 +01:00
|
|
|
|
|
|
|
if data_to_print.is_empty():
|
2023-12-15 22:44:25 +01:00
|
|
|
data_to_print = "<nothing>"
|
2023-06-13 17:23:10 +02:00
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
DeckHolder.logger.log_node(data_to_print)
|