From 4eb5782cf46b3523ba056ba77a5d80a8baa2d484 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Sun, 25 Aug 2024 11:15:42 +0200 Subject: [PATCH] Fix to choice right after condition --- addons/dialogic/Core/DialogicGameHandler.gd | 2 ++ addons/dialogic/Modules/Choice/subsystem_choices.gd | 2 +- addons/dialogic/Modules/Condition/event_condition.gd | 4 ++-- addons/dialogic/Modules/Core/event_end_branch.gd | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/dialogic/Core/DialogicGameHandler.gd b/addons/dialogic/Core/DialogicGameHandler.gd index a0fd1a5e6..43c255744 100644 --- a/addons/dialogic/Core/DialogicGameHandler.gd +++ b/addons/dialogic/Core/DialogicGameHandler.gd @@ -210,6 +210,8 @@ func start_timeline(timeline:Variant, label_or_idx:Variant = "") -> void: current_timeline = timeline current_timeline_events = current_timeline.events + for event in current_timeline_events: + event.dialogic = self current_event_idx = -1 if typeof(label_or_idx) == TYPE_STRING: diff --git a/addons/dialogic/Modules/Choice/subsystem_choices.gd b/addons/dialogic/Modules/Choice/subsystem_choices.gd index 061b1ae7f..14e61a140 100644 --- a/addons/dialogic/Modules/Choice/subsystem_choices.gd +++ b/addons/dialogic/Modules/Choice/subsystem_choices.gd @@ -258,7 +258,7 @@ func is_question(index:int) -> bool: if dialogic.current_timeline_events[index] is DialogicChoiceEvent: if index != 0 and dialogic.current_timeline_events[index-1] is DialogicEndBranchEvent: - if dialogic.current_timeline_events[dialogic.current_timeline_events[index-1].find_opening_index()] is DialogicChoiceEvent: + if dialogic.current_timeline_events[dialogic.current_timeline_events[index-1].find_opening_index(index-1)] is DialogicChoiceEvent: return false else: return true diff --git a/addons/dialogic/Modules/Condition/event_condition.gd b/addons/dialogic/Modules/Condition/event_condition.gd index 0f8bed887..d56f34ac6 100644 --- a/addons/dialogic/Modules/Condition/event_condition.gd +++ b/addons/dialogic/Modules/Condition/event_condition.gd @@ -24,9 +24,9 @@ func _execute() -> void: if condition.is_empty(): condition = "true" - var result :bool= dialogic.Expressions.execute_condition(condition) + var result: bool = dialogic.Expressions.execute_condition(condition) if not result: - var idx :int = dialogic.current_event_idx + var idx: int = dialogic.current_event_idx var ignore := 1 while true: idx += 1 diff --git a/addons/dialogic/Modules/Core/event_end_branch.gd b/addons/dialogic/Modules/Core/event_end_branch.gd index 499029178..60a53dd0d 100644 --- a/addons/dialogic/Modules/Core/event_end_branch.gd +++ b/addons/dialogic/Modules/Core/event_end_branch.gd @@ -34,8 +34,8 @@ func find_next_index() -> int: return idx -func find_opening_index() -> int: - var idx: int = dialogic.current_event_idx +func find_opening_index(at_index:int) -> int: + var idx: int = at_index var ignore: int = 1 while true: