added yl_speak_up.show_fs_add_trade_simple

This commit is contained in:
Sokomine 2021-05-31 16:32:24 +02:00
parent cb7c2214b4
commit bcf6a4062f
3 changed files with 18 additions and 9 deletions

View File

@ -2705,9 +2705,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
-- do not switch target dialog (we are in edit mode)
yl_speak_up.speak_to[pname].target_d_id = nil
-- create a new trade for this dialog and option - with ID "<d_id> <o_id>"
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
yl_speak_up.get_fs_add_trade_simple(player,
tostring(d_id).." "..tostring(o_id)))
yl_speak_up.show_fs_add_trade_simple(player, tostring(d_id).." "..tostring(o_id))
return
-- the player wants to see the previous option/answer

View File

@ -16,8 +16,7 @@ yl_speak_up.input_trade_list = function(player, formname, fields)
-- the player wants to add a new trade
if(fields.trade_list_add_trade) then
-- show the trade config dialog for a new trade
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
yl_speak_up.get_fs_add_trade_simple(player, "new"))
yl_speak_up.show_fs_add_trade_simple(player, "new")
return
end

View File

@ -20,6 +20,20 @@ yl_speak_up.show_fs_trade_simple = function(player, trade_id)
end
-- also provides an easier way to call this function
yl_speak_up.show_fs_add_trade_simple = function(player, trade_id)
if(not(player)) then
return
end
if(not(trade_id) and yl_speak_up.speak_to[pname]) then
trade_id = yl_speak_up.speak_to[pname].trade_id
end
minetest.show_formspec(player:get_player_name(),
"yl_speak_up:add_trade_simple",
yl_speak_up.get_fs_add_trade_simple(player, trade_id))
end
-- possible inputs:
-- fields.edit_trade_simple go on to showing the add_trade_simple formspec
-- fields.abort_trade_simple, ESC, depends on context
@ -115,8 +129,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields)
-- show the edit trade formspec
if(fields.edit_trade_simple) then
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
yl_speak_up.get_fs_add_trade_simple(player, trade.trade_id))
yl_speak_up.show_fs_add_trade_simple(player, trade.trade_id)
return
end
@ -239,8 +252,7 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
-- we return from showing an error message (the player may not have noticed
-- a chat message while viewing a formspec; thus, we showed a formspec message)
if(fields.back_from_error_msg) then
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
yl_speak_up.get_fs_add_trade_simple(player))
yl_speak_up.show_fs_add_trade_simple(player)
return
end