From 712f19656ea3f4d7d3d55d5dccfaec54685f4481 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sat, 1 Oct 2022 07:01:52 +0200 Subject: [PATCH] fixed trade as an action (which shall work diffrently than trade from trade list) --- trade_simple.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/trade_simple.lua b/trade_simple.lua index b5d171e..0ac37ff 100644 --- a/trade_simple.lua +++ b/trade_simple.lua @@ -779,6 +779,24 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id) " Current stock: "..tostring(stock_pay).. " (max: "..tostring(trade.max_storage).. "). Perhaps later?" + -- trade as an action + elseif(not(trade.trade_is_trade_list)) then + if(trade_inv:contains_item("pay", trade.player_gives)) then + -- all good so far; move the price stack to the pay slot + -- move price item to the price slot + local stack = player_inv:remove_item("main", trade.player_gives) + trade_inv:add_item("pay", stack) + trade_possible_msg = "Please take your purchase!" + can_trade = true + elseif(trade_inv:is_empty("pay")) then + trade_possible_msg = "Please insert the right payment in the pay slot\n".. + "and then take your purchase." + can_trade = false + else + trade_possible_msg = "This is not what "..minetest.formspec_escape(trade.npc_name).. + " wants.\nPlease insert the right payment!" + can_trade = false + end -- can the player pay? elseif(not(player_inv:contains_item("main", trade.player_gives))) then -- both slots will remain empty @@ -789,11 +807,6 @@ yl_speak_up.get_fs_trade_simple = function(player, trade_id) -- (the slot may already contain the right things; we'll find that out later on) trade_possible_msg = "This is not what "..minetest.formspec_escape(trade.npc_name).. " wants.\nPlease insert the right payment!" - -- all good so far; move the price stack to the pay slot --- else --- -- move price item to the price slot --- local stack = player_inv:remove_item("main", trade.player_gives) --- trade_inv:add_item("pay", stack) else trade_possible_msg = "Please insert the right payment in the pay slot\n".. "or click on \"buy\"."..