From 60d17124b6445333d2d61a7da79c9bdbed5becb4 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 31 May 2021 21:52:04 +0200 Subject: [PATCH] moved edit_options_dialog to yl_speak_up.show_fs --- functions.lua | 28 +++++++++++++++++++--------- trade_simple.lua | 12 ++++++------ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/functions.lua b/functions.lua index 7891431..30dce5a 100644 --- a/functions.lua +++ b/functions.lua @@ -1800,7 +1800,17 @@ yl_speak_up.show_fs = function(player, fs_name, param) local pname = player:get_player_name() if(fs_name == "TODO") then + elseif(fs_name == "edit_option_dialog") then + if(not(param)) then + param = {} + end + minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", + yl_speak_up.get_fs_edit_option_dialog(player, param.n_id, param.d_id, param.o_id)) + elseif(fs_name == "talk") then + if(not(param)) then + param = {} + end minetest.show_formspec(pname, "yl_speak_up:talk", yl_speak_up.get_fs_talkdialog(player, param.n_id, param.d_id)) @@ -2728,8 +2738,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) local result = yl_speak_up.edit_mode_apply_changes(pname, fields) -- if a new option was added or the target dialog of this one changed, display the right new option if(result and result["show_next_option"] and n_dialog.d_options[result["show_next_option"]]) then - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, result["show_next_option"])) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = d_id, o_id = result["show_next_option"]}) return end @@ -2761,8 +2771,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) end end -- show that dialog; fallback: show the same (o_id) again - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_found)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = d_id, o_id = o_found}) return -- the player wants to see the next option/answer @@ -2776,8 +2786,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) end end -- show that dialog; fallback: show the same (o_id) again - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_found)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = d_id, o_id = o_found}) return -- show the trade associated with this dialog and option @@ -3055,9 +3065,9 @@ yl_speak_up.input_talk = function(player, formname, fields) if( fields["edit_option_"..o_id] or fields["conditions_"..o_id] or fields["effects_"..o_id]) then - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog( - player, yl_speak_up.speak_to[pname].n_id, d_id, o_id)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = yl_speak_up.speak_to[pname].n_id, + d_id = d_id, o_id = o_found}) return end end diff --git a/trade_simple.lua b/trade_simple.lua index fbc3e88..cd6bbbb 100644 --- a/trade_simple.lua +++ b/trade_simple.lua @@ -46,8 +46,8 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields) yl_speak_up.speak_to[pname].target_d_id = nil yl_speak_up.speak_to[pname].trade_id = nil -- go to the edit options dialog - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, tr.d_id, tr.o_id)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = tr.d_id, o_id = tr.o_id}) return end end @@ -121,8 +121,8 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields) -- if in edit mode: go back to the edit options dialog if(yl_speak_up.edit_mode[pname] == n_id and n_id and o_id) then -- go to the edit options dialog - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_id)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = d_id, o_id = o_id}) return -- show either the current or the target dialog elseif(target_dialog) then @@ -381,8 +381,8 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields) -- we are no longer trading yl_speak_up.speak_to[pname].trade_id = nil -- ..else go back to the edit options formspec - minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog", - yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_id)) + yl_speak_up.show_fs(player, "edit_option_dialog", + {n_id = n_id, d_id = d_id, o_id = o_id}) end end