use logger in nodes

This commit is contained in:
Lera Elvoé 2023-12-15 00:04:29 +03:00
parent d67ccdbad2
commit 7e35529100
No known key found for this signature in database
12 changed files with 27 additions and 9 deletions

View file

@ -30,7 +30,7 @@ func handle_delay(data):
pass
print("Delay over")
#print("Delay over")
send(0, data)

View file

@ -33,6 +33,7 @@ func _value_request(_from_port : int) -> Variant:
var err = expr.parse(text, ["deck_var", "input"])
if err != OK:
DeckHolder.logger.log_node("Expression parse failed: %s" % err, Logger.LogType.ERROR)
printerr(err)
return null
@ -40,7 +41,7 @@ func _value_request(_from_port : int) -> Variant:
var res = expr.execute([_belonging_to.variable_stack, request_value(0)])
if expr.has_execute_failed():
printerr("Expression Execution Failed: ", text)
DeckHolder.logger.log_node("Expression Execution Failed: %s" % text, Logger.LogType.ERROR)
return null

View file

@ -41,7 +41,7 @@ func _on_outgoing_connection_removed(port_idx: int) -> void:
if !(outgoing_connections.get(port, {}) as Dictionary).is_empty():
last_connected_port = port
prints("l:", last_connected_port, "p:", port_idx)
#prints("l:", last_connected_port, "p:", port_idx)
if port_idx < last_connected_port:
return

View file

@ -39,7 +39,7 @@ func _on_incoming_connection_removed(port_idx: int) -> void:
if !(incoming_connections[port] as Dictionary).is_empty():
last_connected_port = port
prints("l:", last_connected_port, "p:", port_idx)
#prints("l:", last_connected_port, "p:", port_idx)
if port_idx < last_connected_port:
return

View file

@ -34,9 +34,11 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
if to_input_port != 1:
return
var data_to_print = resolve_input_port_value(0)
if data_to_print == null || data_to_print.is_empty():
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
@ -44,4 +46,6 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
#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)

View file

@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant:
var vb = request_value(1)
if !va || !vb:
DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Add: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
var res := {}

View file

@ -25,9 +25,11 @@ func _init() -> void:
func _value_request(on_port: int) -> Variant:
var v = request_value(0)
if !v:
DeckHolder.logger.log_node("Vector Decompose: the vector is invalid.", Logger.LogType.ERROR)
return null
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Decompose: the vector is invalid.", Logger.LogType.ERROR)
return null
if on_port == 0:

View file

@ -27,12 +27,15 @@ func _value_request(_on_port: int) -> Variant:
var vb = request_value(1)
if !va || !vb:
DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Dot: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
return va.x * vb.x + va.y * vb.y

View file

@ -27,9 +27,11 @@ func _value_request(_on_port: int) -> Variant:
var v = request_value(0)
if !v:
DeckHolder.logger.log_node("Vector Mult: the vector is invalid.", Logger.LogType.ERROR)
return null
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Mult: the vector is invalid.", Logger.LogType.ERROR)
return null
var s = float(resolve_input_port_value(1))

View file

@ -21,9 +21,11 @@ func _init() -> void:
func _value_request(_on_port: int) -> Variant:
var v = request_value(0)
if !v:
DeckHolder.logger.log_node("Vector Normalize: the vector is invalid.", Logger.LogType.ERROR)
return null
if !(v as Dictionary).has("x") || !(v as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Normalize: the vector is invalid.", Logger.LogType.ERROR)
return null
var l: float = (v.x ** 2.0) + (v.y ** 2.0)
@ -34,6 +36,6 @@ func _value_request(_on_port: int) -> Variant:
res.y = res.y / l
return res
print("vector length is 0, can't normalize. returning null")
DeckHolder.logger.log_node("Vector Normalize: the vector is length 0. Returning null.", Logger.LogType.ERROR)
return null

View file

@ -26,12 +26,15 @@ func _value_request(_on_port: int) -> Variant:
var vb = request_value(1)
if !va || !vb:
DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(va as Dictionary).has("x") || !(va as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
if !(vb as Dictionary).has("x") || !(vb as Dictionary).has("y"):
DeckHolder.logger.log_node("Vector Sub: one of the vectors is invalid.", Logger.LogType.ERROR)
return null
var res := {}

View file

@ -195,7 +195,6 @@ func get_selected_nodes() -> Array:
## based off the action "group_nodes".
func _gui_input(event: InputEvent) -> void:
if event.is_action_pressed("group_nodes") && get_selected_nodes().size() > 0:
print("?")
clear_connections()
var nodes = get_selected_nodes().map(
func(x: DeckNodeRendererGraphNode):
@ -222,7 +221,6 @@ func _input(event: InputEvent) -> void:
if event.is_action_pressed("enter_group") && get_selected_nodes().size() == 1:
if !((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.node_type == "group_node"):
return
print("tried to enter group")
group_enter_requested.emit((get_selected_nodes()[0] as DeckNodeRendererGraphNode).node.group_id)
get_viewport().set_input_as_handled()