From bfeed377679d264551ad5e8a76fe3372110eee6a Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 15 Dec 2024 13:50:58 +0100 Subject: [PATCH] allow d_got_item and d_trade to be used as target dialogs and as target for failed actions --- exec_actions.lua | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/exec_actions.lua b/exec_actions.lua index a35c79a..90130f4 100644 --- a/exec_actions.lua +++ b/exec_actions.lua @@ -177,9 +177,10 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam 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}) + -- allow d_end, d_trade, d_got_item etc. to work as a_on_failure + yl_speak_up.show_next_talk_fs_after_action(player, pname, + this_action.a_on_failure, formname, + dialog, d_id, n_id, this_action.alternate_text) return else local this_action = actions[ sorted_key_list[ nr ]] @@ -220,6 +221,26 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam local target_dialog = res.next_dialog yl_speak_up.speak_to[pname].o_id = nil yl_speak_up.speak_to[pname].a_id = nil + + -- the function above returns a target dialog; show that to the player + yl_speak_up.show_next_talk_fs_after_action(player, pname, target_dialog, formname, + dialog, target_dialog, n_id, res.alternate_text) +end + + +-- after completing the action - either successfully or if it failed: +yl_speak_up.show_next_talk_fs_after_action = function(player, pname, target_dialog, formname, + dialog, d_id, n_id, alternate_text) + -- allow to switch to d_trade from any dialog + if(target_dialog and target_dialog == "d_trade") then + yl_speak_up.show_fs(player, "trade_list") + return + end + -- allow to switch to d_got_item from any dialog + if(target_dialog and target_dialog == "d_got_item") then + yl_speak_up.show_fs(player, "player_offers_item") + return + end -- end conversation if(target_dialog and target_dialog == "d_end") then yl_speak_up.stop_talking(pname) @@ -229,18 +250,16 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam end return end + -- the special dialogs d_trade and d_got_item have no actions or effects - thus + -- d_id cannot become d_trade or d_got_item if(not(target_dialog) or target_dialog == "" or not(dialog.n_dialogs[target_dialog])) then target_dialog = d_id end - if(target_dialog and target_dialog == "d_trade") then - yl_speak_up.show_fs(player, "trade_list") - return - end - -- the function above returns a target dialog; show that to the player + -- actually show the next dialog to the player yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog, - alternate_text = res.alternate_text}) + alternate_text = alternate_text}) end