mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 18:20:36 +01:00
avoid lag if full chest, limit items to 50, remove others
This commit is contained in:
parent
2e6ec485b0
commit
9775af22f3
@ -87,9 +87,14 @@ local tube_inject_item = pipeworks.tube_inject_item
|
|||||||
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
local function vacuum(pos, radius)
|
local function vacuum(pos, radius)
|
||||||
radius = radius + 0.5
|
radius = radius + 0.5
|
||||||
|
local max_items = 0
|
||||||
for _, object in pairs(get_objects_inside_radius(pos, sqrt_3 * radius)) do
|
for _, object in pairs(get_objects_inside_radius(pos, sqrt_3 * radius)) do
|
||||||
local lua_entity = object:get_luaentity()
|
local lua_entity = object:get_luaentity()
|
||||||
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
||||||
|
max_items = max_items + 1
|
||||||
|
if max_items > 50 then
|
||||||
|
object:remove()
|
||||||
|
else
|
||||||
local obj_pos = object:getpos()
|
local obj_pos = object:getpos()
|
||||||
local x1, y1, z1 = pos.x, pos.y, pos.z
|
local x1, y1, z1 = pos.x, pos.y, pos.z
|
||||||
local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
|
local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
|
||||||
@ -106,6 +111,7 @@ local function vacuum(pos, radius)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_abm({nodenames = {"group:vacuum_tube"},
|
minetest.register_abm({nodenames = {"group:vacuum_tube"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user