From ef6626842434509c6e8b05a056d9170d064e3bd3 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Thu, 6 Jan 2022 18:05:39 +0100 Subject: [PATCH] if an action fails: switch to the first dialog if no other on_failure dialog is defined --- exec_actions.lua | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/exec_actions.lua b/exec_actions.lua index 1d7f9b0..bb8369f 100644 --- a/exec_actions.lua +++ b/exec_actions.lua @@ -179,31 +179,22 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id) local this_action = actions[ sorted_key_list[ nr ]] -- if there is an on_failure target dialog: go there - if(this_action.a_on_failure) then - -- go back to the same dialog - if(not(dialog.n_dialogs[this_action.a_on_failure])) then - this_action.a_on_failure = d_id - end - -- set the current action to nil - yl_speak_up.speak_to[pname].a_id = nil - -- no option of the new dialog has been selected yet - yl_speak_up.speak_to[pname].o_id = nil - -- show the new dialog - yl_speak_up.debug_msg(player, n_id, o_id, "Action ".. - tostring(a_id).." failed. Switching to dialog ".. - tostring(this_action.a_on_failure)..".") - yl_speak_up.speak_to[pname].d_id = this_action.a_on_failure - yl_speak_up.speak_to[pname].o_id = nil - yl_speak_up.speak_to[pname].a_id = nil - yl_speak_up.show_fs(player, "talk", {n_id = n_id, - d_id = this_action.a_on_failure, - alternate_text = this_action.alternate_text}) - return - else - yl_speak_up.debug_msg(player, n_id, o_id, "Action ".. - tostring(a_id).." failed, but no a_on_failure target ".. - "dialog defined. Continuing execution.") - end + + -- set the current action to nil + yl_speak_up.speak_to[pname].a_id = nil + -- no option of the new dialog has been selected yet + yl_speak_up.speak_to[pname].o_id = nil + -- show the new dialog + yl_speak_up.debug_msg(player, n_id, o_id, "Action ".. + tostring(a_id).." failed. Switching to dialog ".. + tostring(this_action.a_on_failure)..".") + yl_speak_up.speak_to[pname].d_id = this_action.a_on_failure + yl_speak_up.speak_to[pname].o_id = nil + yl_speak_up.speak_to[pname].a_id = nil + yl_speak_up.show_fs(player, "talk", {n_id = n_id, + d_id = this_action.a_on_failure, + alternate_text = this_action.alternate_text}) + return end end -- get the next entry