From 711d326fa4585031b9d623541624826558bdf547 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 21 May 2023 13:12:50 -0400 Subject: Report achievements to AP using data storage (for tracker) --- Archipelago/client.gd | 6 ++++++ Archipelago/load.gd | 12 +++++++++++- Archipelago/notifier.gd | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Archipelago/notifier.gd (limited to 'Archipelago') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 0326ffb..d7074f5 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -540,6 +540,12 @@ func sendLocation(loc_id): _held_locations.append(loc_id) +func setValue(key, value): + sendMessage( + [{"cmd": "Set", "key": key, "operations": [{"operation": "replace", "value": value}]}] + ) + + func completedGoal(): sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 9568f69..052aa84 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -267,12 +267,22 @@ func _load(): painting_node.move_to_z = painting_node.translation.z painting_node.translation.x = 88 painting_node.translation.z = 39 - + var fearless_door = get_node("Doors/Naps Room Doors/Door_hider_5").duplicate() fearless_door.name = "Door_hider_new1" fearless_door.translation.y = 5 get_node("Doors/Naps Room Doors").add_child(fearless_door) + # Set up notifiers for each achievement panel, for the tracker. + var notifier_script = ResourceLoader.load("user://maps/Archipelago/notifier.gd") + for panel in gamedata.panels: + if "achievement" in panel: + var panel_node = panels_parent.get_node(panel["id"]) + var script_instance = notifier_script.new() + script_instance.name = "Achievement_Notifier" + script_instance.key = "Achievement|%s" % panel["achievement"] + panel_node.add_child(script_instance) + # Attach a script to every panel so that we can do things like conditionally # disable them. var panel_script = ResourceLoader.load("user://maps/Archipelago/panel.gd") diff --git a/Archipelago/notifier.gd b/Archipelago/notifier.gd new file mode 100644 index 0000000..57d6564 --- /dev/null +++ b/Archipelago/notifier.gd @@ -0,0 +1,14 @@ +extends Node + +var key + + +func _ready(): + self.get_parent().get_node("Viewport/GUI/Panel/TextEdit").connect( + "answer_correct", self, "handle_correct" + ) + + +func handle_correct(): + var apclient = global.get_node("Archipelago") + apclient.setValue(key, true) -- cgit 1.4.1