From e7959477c917eae78904f04a3d3ff0954d03303c Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sat, 10 Sep 2022 21:46:05 +0200 Subject: [PATCH] allow to set trade limits only when the NPC can be edited by that player --- fs_trade_limit.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs_trade_limit.lua b/fs_trade_limit.lua index 9af6778..fca32b3 100644 --- a/fs_trade_limit.lua +++ b/fs_trade_limit.lua @@ -82,6 +82,11 @@ end -- handle input to the formspec yl_speak_up.input_trade_limit = function(player, formname, fields) + local pname = player:get_player_name() + local n_id = yl_speak_up.speak_to[pname].n_id + if(not(yl_speak_up.may_edit_npc(player, n_id))) then + return + end -- the player has selected an entry - edit it if(fields and fields["edit_trade_limit"]) then local selection = minetest.explode_table_event( fields[ "edit_trade_limit" ]) @@ -98,6 +103,7 @@ yl_speak_up.input_trade_limit = function(player, formname, fields) yl_speak_up.show_fs(player, "trade_list") return end + -- else show this formspec again yl_speak_up.show_fs(player, "trade_limit") end @@ -114,6 +120,10 @@ yl_speak_up.get_fs_trade_limit = function(player, selected) if(not(dialog) or not(n_id)) then return "Error. Missing dialog when accessing trade limits." end + if(not(yl_speak_up.may_edit_npc(player, n_id))) then + return "Error. You have no right to edit this NPC." + end + -- the player has selected an entry - edit it -- make sure all necessary entries in the trades table exist yl_speak_up.setup_trade_limits(dialog)