1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-26 19:00:24 +01:00

Add option to forego real entities (#26)

This commit is contained in:
Jude Melton-Houghton 2022-05-06 11:25:02 -04:00 committed by GitHub
parent 37eef73695
commit 97903327a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 20 deletions

View File

@ -27,6 +27,7 @@ local settings = {
enable_cyclic_mode = true,
drop_on_routing_fail = false,
delete_item_on_clearobject = true,
use_real_entities = true,
}
pipeworks.toggles = {}

View File

@ -73,31 +73,43 @@ local function get_blockpos(pos)
z = math.floor(pos.z / 16)}
end
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
local move_entities_globalstep_part1
local is_active
local move_entities_globalstep_part1 = function(dtime)
local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
local new_active_blocks = {}
for _, player in ipairs(minetest.get_connected_players()) do
local blockpos = get_blockpos(player:get_pos())
local minp = vector.subtract(blockpos, active_block_range)
local maxp = vector.add(blockpos, active_block_range)
if pipeworks.use_real_entities then
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
for x = minp.x, maxp.x do
for y = minp.y, maxp.y do
for z = minp.z, maxp.z do
local pos = {x = x, y = y, z = z}
new_active_blocks[minetest.hash_node_position(pos)] = pos
end
end
move_entities_globalstep_part1 = function(dtime)
local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
local new_active_blocks = {}
for _, player in ipairs(minetest.get_connected_players()) do
local blockpos = get_blockpos(player:get_pos())
local minp = vector.subtract(blockpos, active_block_range)
local maxp = vector.add(blockpos, active_block_range)
for x = minp.x, maxp.x do
for y = minp.y, maxp.y do
for z = minp.z, maxp.z do
local pos = {x = x, y = y, z = z}
new_active_blocks[minetest.hash_node_position(pos)] = pos
end
end
end
end
active_blocks = new_active_blocks
-- todo: callbacks on block load/unload
end
active_blocks = new_active_blocks
-- todo: callbacks on block load/unload
end
local function is_active(pos)
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
is_active = function(pos)
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
end
else
move_entities_globalstep_part1 = function()
end
is_active = function()
return false
end
end
local entitydef_default = {

View File

@ -75,3 +75,6 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false
#Delete item on clearobject.
pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
#Use real visible entities in tubes within active areas.
pipeworks_use_real_entities (Use real entities) bool true