2023-12-15 00:11:31 +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
|
|
|
|
|
2023-07-21 10:10:24 +02:00
|
|
|
var times_activated := 0
|
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
|
|
|
|
func _init() -> void:
|
2023-07-21 07:30:12 +02:00
|
|
|
name = "Print"
|
|
|
|
node_type = name.to_snake_case()
|
2023-12-14 19:15:42 +01:00
|
|
|
description = "Print a value to the console."
|
2023-07-21 07:30:12 +02:00
|
|
|
|
2023-07-21 10:10:24 +02:00
|
|
|
props_to_serialize = [&"times_activated"]
|
2023-11-23 07:38:10 +01:00
|
|
|
category = "general"
|
2023-07-21 10:10:24 +02:00
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
add_input_port(
|
2023-11-28 09:48:16 +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(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.BOOL,
|
2023-06-10 20:23:57 +02:00
|
|
|
"Trigger",
|
|
|
|
"button"
|
|
|
|
)
|
|
|
|
|
2023-06-12 17:32:16 +02:00
|
|
|
add_output_port(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.BOOL,
|
2023-06-12 17:32:16 +02:00
|
|
|
"On Trigger",
|
|
|
|
"label"
|
|
|
|
)
|
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
|
2023-11-26 23:07:15 +01:00
|
|
|
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
|
2023-11-22 05:26:11 +01:00
|
|
|
if to_input_port != 1:
|
2023-06-10 20:23:57 +02:00
|
|
|
return
|
|
|
|
|
2023-12-14 22:04:29 +01:00
|
|
|
var data_to_print = str(resolve_input_port_value(0))
|
|
|
|
if data_to_print == null:
|
2023-11-28 09:48:16 +01:00
|
|
|
data_to_print = str(data)
|
2023-12-14 22:04:29 +01:00
|
|
|
if (data_to_print as String).is_empty():
|
|
|
|
data_to_print = "<nothing>"
|
2023-06-13 17:23:10 +02:00
|
|
|
|
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()
|
2023-12-14 21:47:42 +01:00
|
|
|
#print(data_to_print)
|
|
|
|
#print("extra data: ", extra_data)
|
|
|
|
DeckHolder.logger.log_node(data_to_print)
|
2023-12-14 22:04:29 +01:00
|
|
|
if !extra_data.is_empty():
|
|
|
|
DeckHolder.logger.log_node(str("Extra data: ", extra_data))
|
2023-11-26 23:07:15 +01:00
|
|
|
send(0, true)
|