diff --git a/functions.lua b/functions.lua index 742af2c..b268f01 100644 --- a/functions.lua +++ b/functions.lua @@ -1802,8 +1802,7 @@ yl_speak_up.input_inventory = function(player, formname, fields) yl_speak_up.save_npc_inventory(n_id) -- show the trade list? if(fields.inventory_show_tradelist) then - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end -- ..and go back to the normal talk formspec @@ -2255,8 +2254,7 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t -- the trade list is not really a dialog... if(target_dialog == "trade_list") then - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end -- move on to the target dialog @@ -2981,8 +2979,7 @@ yl_speak_up.input_talk = function(player, formname, fields) yl_speak_up.save_changes_and_switch_to_other_dialog(player, fields, "trade_list") return end - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end diff --git a/trade_list.lua b/trade_list.lua index 02fd15e..07a98b5 100644 --- a/trade_list.lua +++ b/trade_list.lua @@ -1,6 +1,17 @@ -- show a list of all trades +-- provides an easier call for the trade list formspec +yl_speak_up.show_fs_trade_list = function(player) + if(not(player)) then + return + end + minetest.show_formspec(player:get_player_name(), + "yl_speak_up:trade_list", + yl_speak_up.get_fs_trade_list(player)) +end + + -- the player is accessing the trade list yl_speak_up.input_trade_list = function(player, formname, fields) local pname = player:get_player_name() diff --git a/trade_simple.lua b/trade_simple.lua index f1936c5..447293d 100644 --- a/trade_simple.lua +++ b/trade_simple.lua @@ -53,8 +53,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields) -- show the trade list if(fields.back_to_trade_list) then - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end @@ -103,8 +102,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields) yl_speak_up.trade[pname] = nil end -- go back showing the trade list (since we deleted this trade) - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end @@ -275,8 +273,7 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields) -- return the items (setting up the trade was aborted) yl_speak_up.add_trade_simple_return_items(player, trade_inv, pay, buy) -- ..else go back to the edit options formspec - minetest.show_formspec(pname, "yl_speak_up:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) return end -- adding a new trade via the trade list? @@ -408,8 +405,7 @@ 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:trade_list", - yl_speak_up.get_fs_trade_list(player)) + yl_speak_up.show_fs_trade_list(player) else -- we are no longer trading yl_speak_up.speak_to[pname].trade_id = nil