From cf145bb07dad25a8b68f8762b499d1b97a5fbd91 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 31 May 2021 21:41:09 +0200 Subject: [PATCH] moved talk to yl_speak_up.show_fs --- functions.lua | 50 ++++++++++++++++++------------------------------ trade_list.lua | 3 +-- trade_simple.lua | 3 +-- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/functions.lua b/functions.lua index 80d06e4..7891431 100644 --- a/functions.lua +++ b/functions.lua @@ -1800,6 +1800,10 @@ yl_speak_up.show_fs = function(player, fs_name, param) local pname = player:get_player_name() if(fs_name == "TODO") then + elseif(fs_name == "talk") then + minetest.show_formspec(pname, "yl_speak_up:talk", + yl_speak_up.get_fs_talkdialog(player, param.n_id, param.d_id)) + elseif(fs_name == "fashion") then minetest.show_formspec(pname, "yl_speak_up:fashion", yl_speak_up.get_fs_fashion(pname)) @@ -1850,8 +1854,7 @@ yl_speak_up.input_inventory = function(player, formname, fields) return end -- ..and go back to the normal talk formspec - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) end @@ -2194,8 +2197,7 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t -- the player decided to go back and continue editing the current dialog if(edit_mode and fields.back_to_dialog_changes) then -- do NOT clear the list of changes; just show the old dialog again - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) return -- save changes and continue on to the next dialog @@ -2303,8 +2305,7 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t end -- move on to the target dialog yl_speak_up.speak_to[pname].d_id = target_dialog - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, target_dialog)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog}) end @@ -2735,8 +2736,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- back to the main dialog window? -- (this also happens when the last option was deleted) if(fields.show_current_dialog or fields.quit or fields.button_exit or not(d_option) or fields.del_option) then - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) return end @@ -2793,8 +2793,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- if ESC is pressed or anything else unpredicted happens: go back to the main dialog edit window -- reason: don't loose any unsaved changes to the dialog - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) end @@ -2922,8 +2921,7 @@ yl_speak_up.input_talk = function(player, formname, fields) end -- actually start a chat with our new npc - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) return end @@ -2976,8 +2974,7 @@ yl_speak_up.input_talk = function(player, formname, fields) yl_speak_up.edit_mode[pname] = yl_speak_up.speak_to[pname].n_id -- start a new chat - but this time in edit mode yl_speak_up.speak_to[pname].d_id = nil - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, yl_speak_up.speak_to[pname].n_id, nil)) + yl_speak_up.show_fs(player, "talk", {n_id = yl_speak_up.speak_to[pname].n_id, d_id = nil}) return -- end edit mode (does not require the priv; will only switch back to normal behaviour) elseif fields.button_end_edit_mode then @@ -2995,11 +2992,8 @@ yl_speak_up.input_talk = function(player, formname, fields) if fields.button_up then yl_speak_up.speak_to[pname].option_index = yl_speak_up.speak_to[pname].option_index + yl_speak_up.max_number_of_buttons - minetest.show_formspec( - pname, - "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, yl_speak_up.speak_to[pname].n_id, yl_speak_up.speak_to[pname].d_id) - ) + yl_speak_up.show_fs(player, "talk", {n_id = yl_speak_up.speak_to[pname].n_id, + d_id = yl_speak_up.speak_to[pname].d_id}) return elseif fields.button_down then --and yl_speak_up.speak_to[pname].option_index > yl_speak_up.max_number_of_buttons then yl_speak_up.speak_to[pname].option_index = @@ -3007,11 +3001,8 @@ yl_speak_up.input_talk = function(player, formname, fields) if yl_speak_up.speak_to[pname].option_index < 0 then yl_speak_up.speak_to[pname].option_index = 1 end - minetest.show_formspec( - pname, - "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, yl_speak_up.speak_to[pname].n_id, yl_speak_up.speak_to[pname].d_id) - ) + yl_speak_up.show_fs(player, "talk", {n_id = yl_speak_up.speak_to[pname].n_id, + d_id = yl_speak_up.speak_to[pname].d_id}) return else yl_speak_up.speak_to[pname].option_index = 1 @@ -3097,8 +3088,7 @@ yl_speak_up.input_talk = function(player, formname, fields) yl_speak_up.save_changes_and_switch_to_other_dialog(player, fields, show_dialog) -- show the same dialog again else - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) end -- no option was selected - so we need to end this here return @@ -3437,9 +3427,7 @@ function yl_speak_up.talk(self, clicker) yl_speak_up.speak_to[pname].option_index = 1 yl_speak_up.speak_to[pname].obj = self.object - - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(clicker, n_id)) + yl_speak_up.show_fs(clicker, "talk", {n_id = n_id}) end -- ### @@ -3691,8 +3679,8 @@ yl_speak_up.input_fashion = function(player, formname, fields) -- is the player editing this npc? then we need to go back to the edit menu if( yl_speak_up.edit_mode[pname] and yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id) then - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, yl_speak_up.speak_to[pname].n_id, yl_speak_up.speak_to[pname].d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = yl_speak_up.speak_to[pname].n_id, + d_id = yl_speak_up.speak_to[pname].d_id}) return end yl_speak_up.speak_to[pname] = nil diff --git a/trade_list.lua b/trade_list.lua index 3f89a3a..03e0a42 100644 --- a/trade_list.lua +++ b/trade_list.lua @@ -21,8 +21,7 @@ yl_speak_up.input_trade_list = function(player, formname, fields) -- go back to the main dialog if(fields.finished_trading) then - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, d_id)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = d_id}) return end diff --git a/trade_simple.lua b/trade_simple.lua index b1f420f..fbc3e88 100644 --- a/trade_simple.lua +++ b/trade_simple.lua @@ -126,8 +126,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields) return -- show either the current or the target dialog elseif(target_dialog) then - minetest.show_formspec(pname, "yl_speak_up:talk", - yl_speak_up.get_fs_talkdialog(player, n_id, target_dialog)) + yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog}) return end end