mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-05 10:00:26 +01:00
parent
d38fa23ab3
commit
e44dd3e74b
|
@ -116,38 +116,38 @@ end
|
|||
-- Determination and reserved items tick --
|
||||
-------------------------------------------
|
||||
|
||||
local function vacuum_inventory(name, inv, invname)
|
||||
local function vacuum_inventory(name, inv, invname, bury)
|
||||
local ref = minetest.get_player_by_name(name)
|
||||
for i = 1, inv:get_size(invname) do
|
||||
local stack = inv:get_stack(invname, i)
|
||||
if pclasses.data.reserved_items[stack:get_name()] then
|
||||
if not pclasses.api.util.can_have_item(name, stack:get_name()) then
|
||||
inv:set_stack(invname, i, "")
|
||||
local grave_inv = pclasses.api.create_graveyard_inventory(ref)
|
||||
if grave_inv and grave_inv:room_for_item("graveyard", stack) then
|
||||
grave_inv:add_item("graveyard", stack)
|
||||
inv:add_item("graveyard", stack)
|
||||
-- ^ Because add_item doesn't trigger on_put, nonsense
|
||||
else
|
||||
minetest.add_item(ref:getpos(), stack)
|
||||
if bury then
|
||||
local grave_inv = pclasses.api.create_graveyard_inventory(ref)
|
||||
if grave_inv and grave_inv:room_for_item("graveyard", stack) then
|
||||
grave_inv:add_item("graveyard", stack)
|
||||
inv:add_item("graveyard", stack)
|
||||
-- ^ Because add_item doesn't trigger on_put, nonsense
|
||||
else
|
||||
minetest.add_item(ref:getpos(), stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function tick()
|
||||
for id, ref in ipairs(minetest.get_connected_players()) do
|
||||
local name = ref:get_player_name()
|
||||
local armor_inv = minetest.get_inventory({type = "detached", name = name .. "_armor"})
|
||||
local inv = ref:get_inventory()
|
||||
vacuum_inventory(name, inv, "main")
|
||||
vacuum_inventory(name, inv, "armor")
|
||||
-- Hack the hack
|
||||
for i = 1, armor_inv:get_size("armor") do
|
||||
armor_inv:set_stack("armor", i, inv:get_stack("armor", i))
|
||||
end
|
||||
|
||||
vacuum_inventory(name, inv, "main", true)
|
||||
vacuum_inventory(name, inv, "armor", true)
|
||||
vacuum_inventory(name, armor_inv, "armor", false) -- Don't move to the graveyard
|
||||
|
||||
armor:set_player_armor(ref)
|
||||
armor:update_inventory(ref)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user