allow to set trade limits only when the NPC can be edited by that player
This commit is contained in:
parent
8b9edead0e
commit
e7959477c9
@ -82,6 +82,11 @@ end
|
|||||||
|
|
||||||
-- handle input to the formspec
|
-- handle input to the formspec
|
||||||
yl_speak_up.input_trade_limit = function(player, formname, fields)
|
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
|
-- the player has selected an entry - edit it
|
||||||
if(fields and fields["edit_trade_limit"]) then
|
if(fields and fields["edit_trade_limit"]) then
|
||||||
local selection = minetest.explode_table_event( fields[ "edit_trade_limit" ])
|
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")
|
yl_speak_up.show_fs(player, "trade_list")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- else show this formspec again
|
-- else show this formspec again
|
||||||
yl_speak_up.show_fs(player, "trade_limit")
|
yl_speak_up.show_fs(player, "trade_limit")
|
||||||
end
|
end
|
||||||
@ -114,6 +120,10 @@ yl_speak_up.get_fs_trade_limit = function(player, selected)
|
|||||||
if(not(dialog) or not(n_id)) then
|
if(not(dialog) or not(n_id)) then
|
||||||
return "Error. Missing dialog when accessing trade limits."
|
return "Error. Missing dialog when accessing trade limits."
|
||||||
end
|
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
|
-- make sure all necessary entries in the trades table exist
|
||||||
yl_speak_up.setup_trade_limits(dialog)
|
yl_speak_up.setup_trade_limits(dialog)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user