forked from your-land-mirror/yl_speak_up
split fs_add_trade_simple into editor/ and rest
This commit is contained in:
parent
1659aed8ab
commit
0f6962e0a8
@ -430,7 +430,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
|
|||||||
-- the button is called store_trade_simple instead of save_element in
|
-- the button is called store_trade_simple instead of save_element in
|
||||||
-- the trade simple function(s); we want to store a trade
|
-- the trade simple function(s); we want to store a trade
|
||||||
fields.store_trade_simple = true
|
fields.store_trade_simple = true
|
||||||
local res = yl_speak_up.input_add_trade_simple(player, "", fields)
|
local res = yl_speak_up.input_add_trade_simple(player, "", fields, nil)
|
||||||
-- the above function sets:
|
-- the above function sets:
|
||||||
-- dialog.trades[ trade_id ] = {pay={ps},buy={bs}, d_id = d_id, o_id = o_id}
|
-- dialog.trades[ trade_id ] = {pay={ps},buy={bs}, d_id = d_id, o_id = o_id}
|
||||||
-- store the trade as an action:
|
-- store the trade as an action:
|
||||||
|
@ -68,3 +68,27 @@ yl_speak_up.delete_trade_simple = function(player, trade_id)
|
|||||||
end
|
end
|
||||||
return old_delete_trade_simple(player, trade_id)
|
return old_delete_trade_simple(player, trade_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- override fs/fs_add_trade_simple.lua:
|
||||||
|
-- (this is kept here as it is trade related and does not change the formspec as such)
|
||||||
|
|
||||||
|
local old_input_add_trade_simple = yl_speak_up.input_add_trade_simple
|
||||||
|
yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to)
|
||||||
|
if(not(player)) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
|
||||||
|
input_to = "add_trade_simple"
|
||||||
|
-- are we editing an action of the type trade?
|
||||||
|
if( yl_speak_up.speak_to[pname][ "tmp_action" ]
|
||||||
|
and yl_speak_up.speak_to[pname][ "tmp_action" ].what == 3
|
||||||
|
and yl_speak_up.in_edit_mode(pname)
|
||||||
|
and yl_speak_up.edit_mode[pname] == n_id) then
|
||||||
|
input_to = "edit_actions"
|
||||||
|
end
|
||||||
|
|
||||||
|
return old_input_add_trade_simple(player, formname, fields, input_to)
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -80,17 +80,14 @@ end
|
|||||||
-- go back to edit options dialog
|
-- go back to edit options dialog
|
||||||
-- abort_trade_simple, ESC go back to edit options dialog
|
-- abort_trade_simple, ESC go back to edit options dialog
|
||||||
-- The rest is inventory item movement.
|
-- The rest is inventory item movement.
|
||||||
yl_speak_up.input_add_trade_simple = function(player, formname, fields)
|
yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to)
|
||||||
if(not(player)) then
|
if(not(player)) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
|
|
||||||
local input_to = "add_trade_simple"
|
if(not(input_to)) then
|
||||||
-- are we editing an action of the type trade?
|
input_to = "add_trade_simple"
|
||||||
if( yl_speak_up.speak_to[pname][ "tmp_action" ]
|
|
||||||
and yl_speak_up.speak_to[pname][ "tmp_action" ].what == 3) then
|
|
||||||
input_to = "edit_actions"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- we return from showing an error message (the player may not have noticed
|
-- we return from showing an error message (the player may not have noticed
|
||||||
@ -132,7 +129,7 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
|
|||||||
local o_id = yl_speak_up.speak_to[pname].o_id
|
local o_id = yl_speak_up.speak_to[pname].o_id
|
||||||
|
|
||||||
-- the trade can only be changed in edit mode
|
-- the trade can only be changed in edit mode
|
||||||
if((not(n_id) or yl_speak_up.edit_mode[pname] ~= n_id)
|
if((input_to == "add_trade_simple")
|
||||||
-- exception: when adding a new trade via the trade list
|
-- exception: when adding a new trade via the trade list
|
||||||
-- (that is allowed without having to be in edit mode)
|
-- (that is allowed without having to be in edit mode)
|
||||||
and not(trade_id == "new" and yl_speak_up.may_edit_npc(player, n_id))) then
|
and not(trade_id == "new" and yl_speak_up.may_edit_npc(player, n_id))) then
|
||||||
@ -254,7 +251,7 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
|
|||||||
dialog.trades = {}
|
dialog.trades = {}
|
||||||
end
|
end
|
||||||
if(dialog.trades[ trade_id ] and dialog.trades[ trade_id ].d_id
|
if(dialog.trades[ trade_id ] and dialog.trades[ trade_id ].d_id
|
||||||
and input_to ~= "edit_actions") then
|
and input_to == "add_trade_simple") then
|
||||||
yl_speak_up.speak_to[pname].trade_id = trade_id
|
yl_speak_up.speak_to[pname].trade_id = trade_id
|
||||||
-- tell the player that the new trade has been added
|
-- tell the player that the new trade has been added
|
||||||
yl_speak_up.show_fs(player, "msg", {
|
yl_speak_up.show_fs(player, "msg", {
|
||||||
|
Loading…
Reference in New Issue
Block a user