forked from Sokomine/yl_speak_up
added yl_speak_up.show_fs_trade_simple
This commit is contained in:
parent
f772f6aa64
commit
cb7c2214b4
@ -2747,9 +2747,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
|
|||||||
-- do not switch target dialog (we are in edit mode)
|
-- do not switch target dialog (we are in edit mode)
|
||||||
yl_speak_up.speak_to[pname].target_d_id = nil
|
yl_speak_up.speak_to[pname].target_d_id = nil
|
||||||
-- show the trade with ID "<d_id> <o_id>"
|
-- show the trade with ID "<d_id> <o_id>"
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player, tostring(d_id).." "..tostring(o_id))
|
||||||
yl_speak_up.get_fs_trade_simple(player,
|
|
||||||
tostring(d_id).." "..tostring(o_id)))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3219,8 +3217,7 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
|||||||
-- which dialog shall be shown in case of a successful trade?
|
-- which dialog shall be shown in case of a successful trade?
|
||||||
yl_speak_up.speak_to[pname].target_d_id = target_dialog
|
yl_speak_up.speak_to[pname].target_d_id = target_dialog
|
||||||
-- show the trade dialog
|
-- show the trade dialog
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player, trade_id)
|
||||||
yl_speak_up.get_fs_trade_simple(player, trade_id))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@ yl_speak_up.input_trade_list = function(player, formname, fields)
|
|||||||
-- normal mode: the player wants to see a particular trade
|
-- normal mode: the player wants to see a particular trade
|
||||||
for k,v in pairs(dialog.trades) do
|
for k,v in pairs(dialog.trades) do
|
||||||
if(fields[ k ]) then
|
if(fields[ k ]) then
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player, k)
|
||||||
yl_speak_up.get_fs_trade_simple(player, k))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,20 @@ yl_speak_up.trade_fail_fs = "size[6,2]"..
|
|||||||
"button_exit[2,1.5;1,0.9;exit;Exit]"
|
"button_exit[2,1.5;1,0.9;exit;Exit]"
|
||||||
|
|
||||||
|
|
||||||
|
-- provides an easier call for the trade simple formspec
|
||||||
|
yl_speak_up.show_fs_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:do_trade_simple",
|
||||||
|
yl_speak_up.get_fs_trade_simple(player, trade_id))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- possible inputs:
|
-- possible inputs:
|
||||||
-- fields.edit_trade_simple go on to showing the add_trade_simple formspec
|
-- fields.edit_trade_simple go on to showing the add_trade_simple formspec
|
||||||
-- fields.abort_trade_simple, ESC, depends on context
|
-- fields.abort_trade_simple, ESC, depends on context
|
||||||
@ -32,9 +46,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields)
|
|||||||
|
|
||||||
-- a new trade has been stored - show it
|
-- a new trade has been stored - show it
|
||||||
if(fields.trade_simple_stored) then
|
if(fields.trade_simple_stored) then
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player, yl_speak_up.speak_to[pname].trade_id)
|
||||||
yl_speak_up.get_fs_trade_simple(player,
|
|
||||||
yl_speak_up.speak_to[pname].trade_id))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -138,8 +150,7 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- show this formspec again
|
-- show this formspec again
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player)
|
||||||
yl_speak_up.get_fs_trade_simple(player))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -725,8 +736,7 @@ minetest.register_on_joinplayer(function(player, last_login)
|
|||||||
if(listname == "pay") then
|
if(listname == "pay") then
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
-- show formspec with updated information (perhaps sale is now possible)
|
-- show formspec with updated information (perhaps sale is now possible)
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player)
|
||||||
yl_speak_up.get_fs_trade_simple(player))
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_take = function(inv, listname, index, stack, player)
|
on_take = function(inv, listname, index, stack, player)
|
||||||
@ -735,14 +745,12 @@ minetest.register_on_joinplayer(function(player, last_login)
|
|||||||
if(listname == "pay") then
|
if(listname == "pay") then
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
-- show formspec with updated information (perhaps sale is now possible)
|
-- show formspec with updated information (perhaps sale is now possible)
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player)
|
||||||
yl_speak_up.get_fs_trade_simple(player))
|
|
||||||
elseif(listname == "buy") then
|
elseif(listname == "buy") then
|
||||||
yl_speak_up.do_trade_simple(player, stack:get_count())
|
yl_speak_up.do_trade_simple(player, stack:get_count())
|
||||||
-- information may require an update (NPC might now be out of stock), or
|
-- information may require an update (NPC might now be out of stock), or
|
||||||
-- the player can do the trade a second time
|
-- the player can do the trade a second time
|
||||||
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
|
yl_speak_up.show_fs_trade_simple(player)
|
||||||
yl_speak_up.get_fs_trade_simple(player))
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user