brackeys-12/components/Triggerer/trigger_receiver.gd

23 lines
422 B
GDScript3
Raw Permalink Normal View History

2024-09-08 17:34:41 +00:00
@icon("res://components/Triggerer/antenna.svg")
class_name TriggerReceiver
extends Node
signal received(data: Dictionary)
@export var keys: Array[String]
var _triggerer
func _ready():
if get_tree().root.has_node("Triggerer"):
_triggerer = get_tree().root.get_node("Triggerer")
if _triggerer:
for key in keys:
_triggerer.listen(key, _on_received)
func _on_received(data: Dictionary):
received.emit(data)