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