From 8b70448bf7feea2387d4b82aa23e9b7ca9f73717 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Sun, 7 Nov 2021 23:46:13 +0100 Subject: [PATCH] fix: Fixes skipping empty or comment lines in groups and dialogs (#429) Co-authored-by: Dennis Ploeger --- .../game/core-scripts/esc/_test/test_esc_compiler.gd | 6 +++--- .../escoria-core/game/core-scripts/esc/esc_compiler.gd | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/esc/_test/test_esc_compiler.gd b/addons/escoria-core/game/core-scripts/esc/_test/test_esc_compiler.gd index dc183dcf..2141d163 100644 --- a/addons/escoria-core/game/core-scripts/esc/_test/test_esc_compiler.gd +++ b/addons/escoria-core/game/core-scripts/esc/_test/test_esc_compiler.gd @@ -13,6 +13,7 @@ func _test_basic() -> bool: say player "Test3" [test2] # Third group > + say player "Test4" # Fourth group > @@ -177,11 +178,10 @@ func _test_event_flags() -> bool: var script = escoria.esc_compiler.compile(esc.split("\n")) var subject = script.events - assert(subject.keys().size() == 4) + assert(subject.keys().size() == 3) assert("test" in subject.keys()) assert("test2" in subject.keys()) assert("test3" in subject.keys()) - assert("test4" in subject.keys()) subject = script.events["test"] assert(subject.name == "test") @@ -279,7 +279,7 @@ func _test_dialog() -> bool: subject = script.events["test"].statements[0].options[3] assert(subject is ESCDialogOption) - assert(subject.option == "TEST:Option 4") + assert(subject.option == "TEST") return true diff --git a/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd b/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd index b30e9ce6..da955d50 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd @@ -139,6 +139,9 @@ func _compile(lines: Array) -> Array: var group_lines = [] while lines.size() > 0: var next_line = lines.pop_front() + if comment_regex.search(next_line) or \ + empty_regex.search(next_line): + continue var next_line_indent = \ escoria.utils.get_re_group( indent_regex.search(next_line), @@ -162,6 +165,9 @@ func _compile(lines: Array) -> Array: var dialog_lines = [] while lines.size() > 0: var next_line = lines.pop_front() + if comment_regex.search(next_line) or \ + empty_regex.search(next_line): + continue var end_line = dialog_end_regex.search(next_line) if end_line and \ escoria.utils.get_re_group( @@ -189,6 +195,9 @@ func _compile(lines: Array) -> Array: var dialog_option_lines = [] while lines.size() > 0: var next_line = lines.pop_front() + if comment_regex.search(next_line) or \ + empty_regex.search(next_line): + continue var next_line_indent = \ escoria.utils.get_re_group( indent_regex.search(next_line),