mirror of
https://gitlab.com/lunovox/minertrade.git
synced 2025-03-21 16:01:22 +00:00
Correção de bug de estoque superlotado.
(Estava apagando o item)
This commit is contained in:
parent
71b4feef63
commit
88948f10b9
2 changed files with 31 additions and 7 deletions
|
@ -247,28 +247,40 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
if wants == nil or gives == nil then return end -- do not crash the server
|
if wants == nil or gives == nil then return end -- do not crash the server
|
||||||
-- Check if we can exchange
|
-- Check if we can exchange
|
||||||
local can_exchange = true
|
local can_exchange = true
|
||||||
local owners_fault = false
|
local error_name = ""
|
||||||
for i, item in pairs(wants) do
|
for i, item in pairs(wants) do
|
||||||
if not pinv:contains_item("customer_gives",item) then
|
if not pinv:contains_item("customer_gives",item) then
|
||||||
can_exchange = false
|
can_exchange = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if not minv:room_for_item("customers_gave",item) then -- verifica se compartimento de Recebimento de pagamento do vendedor tem espaço
|
||||||
|
can_exchange = false
|
||||||
|
error_name = "without_space_to_profit"
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, item in pairs(gives) do
|
for i, item in pairs(gives) do
|
||||||
if not minv:contains_item("stock",item) then
|
if not minv:contains_item("stock",item) then
|
||||||
can_exchange = false
|
can_exchange = false
|
||||||
owners_fault = true
|
error_name = "owners_fault"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if not pinv:room_for_item("customer_gets",item) then -- verifica se a caixa de entrega ao jogador tem espaço
|
||||||
|
can_exchange = false
|
||||||
|
error_name = "without_space_to_offer"
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.quit==nil then
|
if fields.quit==nil then
|
||||||
if can_exchange then
|
if can_exchange then
|
||||||
for i, item in pairs(wants) do
|
for i, item in pairs(wants) do
|
||||||
pinv:remove_item("customer_gives",item)
|
pinv:remove_item("customer_gives",item) --Remove do compartimento de Oferta de pagamento
|
||||||
minv:add_item("customers_gave",item)
|
minv:add_item("customers_gave",item) --Adiciona do compartimento de Recebimento de pagamento
|
||||||
end
|
end
|
||||||
for i, item in pairs(gives) do
|
for i, item in pairs(gives) do
|
||||||
minv:remove_item("stock",item)
|
minv:remove_item("stock",item) -- Remove do Estoque
|
||||||
pinv:add_item("customer_gets",item)
|
pinv:add_item("customer_gets",item) -- Entrega ao jogador.
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
||||||
|
@ -276,11 +288,21 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
)
|
)
|
||||||
minetest.sound_play("sfx_cash_register", {object=sender, max_hear_distance=5.0,})
|
minetest.sound_play("sfx_cash_register", {object=sender, max_hear_distance=5.0,})
|
||||||
else
|
else
|
||||||
if owners_fault then
|
if error_name == "owners_fault" then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
||||||
..modMinerTrade.translate("The stock of '%s' is gone. Contact him!"):format(owner)
|
..modMinerTrade.translate("The stock of '%s' is gone. Contact him!"):format(owner)
|
||||||
)
|
)
|
||||||
|
elseif error_name == "without_space_to_profit" then
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
||||||
|
..modMinerTrade.translate("Without enough space in Dispensing Machine to receive the customer item. (Please, contact the seller '%s'!)"):format(owner)
|
||||||
|
)
|
||||||
|
elseif error_name == "without_space_to_offer" then
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
||||||
|
..modMinerTrade.translate("Without enough space in Dispensing Machine to receive the seller's item. (Please, empty the receiving box!)")
|
||||||
|
)
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
|
||||||
|
|
|
@ -34,6 +34,8 @@ Dispensing Machine of '%s'.=Maquina Dispensadora de '%s'.
|
||||||
The Dispensing Machine can not be removed before being emptied!=A Máquina Dispensadora não pode ser retirada antes de ser esvaziada!
|
The Dispensing Machine can not be removed before being emptied!=A Máquina Dispensadora não pode ser retirada antes de ser esvaziada!
|
||||||
You can not change your own machine!=Voce nao pode trocar na sua propria maquina!
|
You can not change your own machine!=Voce nao pode trocar na sua propria maquina!
|
||||||
The stock of '%s' is gone. Contact him!=O estoque de '%s' acabou. Contacte-o!
|
The stock of '%s' is gone. Contact him!=O estoque de '%s' acabou. Contacte-o!
|
||||||
|
Without enough space in Dispensing Machine to receive the customer item. (Please, contact the seller '%s'!)=Sem espaço suficiente na Maquina Dispensadora para receber o item do cliente. (Por favor, entre em contato com o vendedor '%s'!)
|
||||||
|
Without enough space in Dispensing Machine to receive the seller's item. (Please, empty the receiving box!)=Sem espaço suficiente na Maquina Dispensadora para receber o item do vendedor. (Por favor, esvazie a caixa de recebimento!)
|
||||||
The dispending can not be done. Make sure you offer what the machine asks for!=A dispensa não pode ser feita. Verifique se você ofereceu o que a máquina pede!
|
The dispending can not be done. Make sure you offer what the machine asks for!=A dispensa não pode ser feita. Verifique se você ofereceu o que a máquina pede!
|
||||||
|
|
||||||
#------- item_exchange_table.lua ---------------------------------------------------------------------------
|
#------- item_exchange_table.lua ---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue