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 89702c15..4c69d8a4 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 @@ -18,6 +18,7 @@ func _test_basic() -> bool: > say player "Test5" say player "Test 6" + say player TEST:"Test 7" """ var script = escoria.esc_compiler.compile(esc.split("\n")) @@ -70,12 +71,17 @@ func _test_basic() -> bool: subject = script.events["test"].statements[1] assert(subject is ESCGroup) - assert(subject.statements.size() == 2) + assert(subject.statements.size() == 3) subject = script.events["test"].statements[1].statements[1] assert(subject is ESCCommand) assert(subject.name == "say") - assert(subject.parameters[1] == "Test 6") + assert(subject.parameters[1] == "Test 6") + + subject = script.events["test"].statements[1].statements[2] + assert(subject is ESCCommand) + assert(subject.name == "say") + assert(subject.parameters[1] == "TEST:Test 7") return true @@ -222,6 +228,8 @@ func _test_dialog() -> bool: - "Option 3" > say player "test3" + - TEST:"Option 4" + say player "test4" ! """ var script = escoria.esc_compiler.compile(esc.split("\n")) @@ -230,7 +238,7 @@ func _test_dialog() -> bool: assert(subject.size() == 1) assert(subject[0] is ESCDialog) - assert(subject[0].options.size() == 3) + assert(subject[0].options.size() == 4) subject = script.events["test"].statements[0].options[0] assert(subject is ESCDialogOption) @@ -276,6 +284,10 @@ func _test_dialog() -> bool: assert(subject[0].statements[0] is ESCCommand) assert(subject[0].statements[0].parameters.size() == 2) + subject = script.events["test"].statements[0].options[3] + assert(subject is ESCDialogOption) + assert(subject.option == "TEST:Option 4") + return true diff --git a/addons/escoria-core/game/core-scripts/esc/commands/say.gd b/addons/escoria-core/game/core-scripts/esc/commands/say.gd index 32273aaa..6f8fe4c0 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/say.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/say.gd @@ -1,7 +1,14 @@ # `say object text [type] [avatar]` # # Runs the specified string as a dialog said by the object. Blocks execution -# until the dialog finishes playing. Optional parameters: +# until the dialog finishes playing. +# +# The text supports translation keys by prepending the key and separating +# it with a `:` from the text. +# +# Example: `say player ROOM1_PICTURE:"Picture's looking good."` +# +# Optional parameters: # # * "type" determines the type of dialog UI to use. Default value is "default" # * "avatar" determines the avatar to use for the dialog. Default value is @@ -64,11 +71,15 @@ func run(command_params: Array) -> int: ] ) return ESCExecution.RC_ERROR - + + var _line = command_params[1] + if ":" in _line: + _line = tr(_line.split(":")[0]) + escoria.dialog_player.say( command_params[0], dialog_scene_name, - command_params[1] + _line ) yield(escoria.dialog_player, "dialog_line_finished") return ESCExecution.RC_OK diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd index 68ba9f88..c063a8a3 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd @@ -46,6 +46,9 @@ func _init(command_string): parameters.append( parameter.substr(1, parameter.length() - 2) ) + elif ":" in parameter and '"' in parameter: + quote_open = true + parameter_values.append(parameter.replace('"', '')) elif parameter.begins_with('"'): quote_open = true parameter_values.append(parameter.substr(1)) diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_dialog_option.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_dialog_option.gd index f481be2b..1cc5599a 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_dialog_option.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_dialog_option.gd @@ -5,11 +5,12 @@ class_name ESCDialogOption # Regex that matches dialog option lines const REGEX = \ - '^[^-]*- "(?