fix: returns an appropriate RC code when no more options are left at a particular dialog level; this has the somewhat beneficial side effect of moving up a level in dialog if there is one, although this requires a 'stop' command to be present in at least one of the top-most dialog options.

This commit is contained in:
Duncan Brown
2022-12-03 13:24:27 -05:00
committed by Julian Murgia
parent 9b27bc4b24
commit 328e5efdd9
2 changed files with 29 additions and 6 deletions

View File

@@ -90,9 +90,17 @@ func run():
escoria.dialog_player,
"option_chosen"
) as ESCDialogOption
var rc = option.run()
if rc is GDScriptFunctionState:
rc = yield(rc, "completed")
if rc != ESCExecution.RC_CANCEL:
return self.run()
var rc = ESCExecution.RC_OK
# If no valid option was returned, it means this level of dialog is done.
# If this is the case and the current level of dialog has a parent, it means
# it is still yielding and so will be shown again.
if option:
rc = option.run()
if rc is GDScriptFunctionState:
rc = yield(rc, "completed")
if rc != ESCExecution.RC_CANCEL:
return self.run()
return rc