From ab632f455def5cefb04ea9fa46beb9445a7d9b52 Mon Sep 17 00:00:00 2001 From: wooshings Date: Sat, 5 Sep 2026 14:57:38 -0700 Subject: [PATCH] resources for choices and branches --- backend/scenes/game.tscn | 17 +++++++++++++++++ dialogue/scripts/choice.gd | 2 ++ dialogue/scripts/dialogue.gd | 2 +- dialogue/scripts/spawn_dialogue.gd | 16 +++++++++++++--- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/backend/scenes/game.tscn b/backend/scenes/game.tscn index 6b21543..11947f1 100644 --- a/backend/scenes/game.tscn +++ b/backend/scenes/game.tscn @@ -10,9 +10,26 @@ script = ExtResource("2_6pot5") dialogue = "this is a test scene for the dialogue system" metadata/_custom_type_script = "uid://dw5jr50hsls5n" +[sub_resource type="Resource" id="Resource_iree2"] +script = ExtResource("2_6pot5") +dialogue = "hehe, well come here and do it hot stuff.." +metadata/_custom_type_script = "uid://dw5jr50hsls5n" + +[sub_resource type="Resource" id="Resource_6pot5"] +script = ExtResource("4_hiff8") +dialogue = Array[ExtResource("2_6pot5")]([SubResource("Resource_iree2")]) +metadata/_custom_type_script = "uid://cu54e7uh65lq0" + +[sub_resource type="Resource" id="Resource_2y53n"] +script = ExtResource("3_iree2") +response = "fuck you" +scene = SubResource("Resource_6pot5") +metadata/_custom_type_script = "uid://d2d5w1vmd71js" + [sub_resource type="Resource" id="Resource_2c6wc"] script = ExtResource("2_6pot5") dialogue = "this is the next line the character is saying" +choices = Array[ExtResource("3_iree2")]([SubResource("Resource_2y53n")]) metadata/_custom_type_script = "uid://dw5jr50hsls5n" [sub_resource type="Resource" id="Resource_qfeqt"] diff --git a/dialogue/scripts/choice.gd b/dialogue/scripts/choice.gd index a1820eb..42a0800 100644 --- a/dialogue/scripts/choice.gd +++ b/dialogue/scripts/choice.gd @@ -1,3 +1,5 @@ extends Resource class_name Choice +@export var response: String +@export var scene: DialogueScene diff --git a/dialogue/scripts/dialogue.gd b/dialogue/scripts/dialogue.gd index 0a48339..942c892 100644 --- a/dialogue/scripts/dialogue.gd +++ b/dialogue/scripts/dialogue.gd @@ -3,4 +3,4 @@ class_name Dialogue @export var character: Character @export_multiline() var dialogue: String -@export var choice: Dictionary[Choice, Dialogue] +@export var choices: Array[Choice] diff --git a/dialogue/scripts/spawn_dialogue.gd b/dialogue/scripts/spawn_dialogue.gd index b578358..f1396d2 100644 --- a/dialogue/scripts/spawn_dialogue.gd +++ b/dialogue/scripts/spawn_dialogue.gd @@ -2,7 +2,7 @@ extends Node class_name DialogueEncounter var dialogue: DialogueScene -signal step +signal step() func _init(path: Resource) -> void: self.dialogue = path @@ -13,6 +13,16 @@ func _input(_event: InputEvent) -> void: step.emit() func Start(): - for i in self.dialogue.get_scene(): - print(i.dialogue) + await walk_scene(self.dialogue) + +func walk_scene(next_scene: DialogueScene): + print("walking scene") + for scene in next_scene.get_scene(): + print(scene.dialogue) + if scene.choices.size() > 0: + for choice in scene.choices: + print(choice.response) + if Input.is_key_pressed(KEY_1): + await walk_scene(scene.choices[0].scene) + step.emit() await step