1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-05-10 20:50:22 +02:00

use minetest.get_objects_in_area and bump to 5.4

This commit is contained in:
OgelGames 2022-11-11 14:49:31 +11:00
parent 0d54b1699b
commit 4f27525cd3
2 changed files with 10 additions and 22 deletions

View File

@ -2,4 +2,4 @@ name = pipeworks
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
depends = basic_materials
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests
min_minetest_version = 5.2.0
min_minetest_version = 5.4.0

View File

@ -5,25 +5,14 @@ local enable_max = minetest.settings:get_bool("pipeworks_enable_items_per_tube_l
local max_items = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
max_items = math.ceil(max_items / 2) -- Limit vacuuming to half the max limit
local sqrtof3 = math.sqrt(3) -- Distance between opposite corners of a 1x1x1 cube
local function inside_area(p, minp, maxp)
if p.x < minp.x or p.x > maxp.x then return false end
if p.y < minp.y or p.y > maxp.y then return false end
if p.z < minp.z or p.z > maxp.z then return false end
return true
end
local function vacuum(pos, radius)
radius = radius + 0.5
local min_pos = vector.subtract(pos, radius)
local max_pos = vector.add(pos, radius)
local count = 0
for _, obj in pairs(minetest.get_objects_inside_radius(pos, radius * sqrtof3)) do
for _, obj in pairs(minetest.get_objects_in_area(min_pos, max_pos)) do
local entity = obj:get_luaentity()
if entity and entity.name == "__builtin:item" then
local obj_pos = obj:get_pos()
if inside_area(obj_pos, min_pos, max_pos) then
if entity.itemstring ~= "" then
pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), entity.itemstring)
entity.itemstring = ""
@ -35,7 +24,6 @@ local function vacuum(pos, radius)
end
end
end
end
end
local function set_timer(pos)