forked from your-land-mirror/yl_speak_up
taking the purchase in a trade_simple inside an action finished the action successfully
This commit is contained in:
parent
045f9b51f0
commit
3104889208
@ -940,7 +940,32 @@ yl_speak_up.player_joined_add_trade_inv = function(player, last_login)
|
||||
-- show formspec with updated information (perhaps sale is now possible)
|
||||
yl_speak_up.show_fs(player, "trade_simple")
|
||||
elseif(listname == "buy") then
|
||||
-- do the exchange
|
||||
yl_speak_up.do_trade_simple(player, stack:get_count())
|
||||
local pname = player:get_player_name()
|
||||
-- which trade are we talking about?
|
||||
local trade = yl_speak_up.trade[pname]
|
||||
-- when the player traded once inside an action: that action was a success;
|
||||
-- execute next action
|
||||
-- but only if not in edit mode
|
||||
if(trade and trade.trade_done > 0
|
||||
and not(trade.trade_is_trade_list)
|
||||
and yl_speak_up.edit_mode[pname] ~= trade.n_id) then
|
||||
local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname})
|
||||
-- return surplus items from the pay slot
|
||||
local pay = trade_inv:get_stack("pay", 1)
|
||||
local player_inv = player:get_inventory()
|
||||
if( pay and player_inv:room_for_item("main", pay)) then
|
||||
player_inv:add_item("main", pay)
|
||||
trade_inv:set_stack("pay", 1, "")
|
||||
end
|
||||
-- done trading
|
||||
yl_speak_up.speak_to[pname].target_d_id = nil
|
||||
yl_speak_up.speak_to[pname].trade_id = nil
|
||||
-- execute the next action
|
||||
yl_speak_up.execute_next_action(player, trade.a_id, true)
|
||||
return
|
||||
end
|
||||
-- information may require an update (NPC might now be out of stock), or
|
||||
-- the player can do the trade a second time
|
||||
yl_speak_up.show_fs(player, "trade_simple")
|
||||
|
Loading…
Reference in New Issue
Block a user