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,9 +73,13 @@ local function get_blockpos(pos)
z = math.floor(pos.z / 16)}
end
local move_entities_globalstep_part1
local is_active
if pipeworks.use_real_entities then
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
local move_entities_globalstep_part1 = function(dtime)
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
@ -96,9 +100,17 @@ local move_entities_globalstep_part1 = function(dtime)
-- todo: callbacks on block load/unload
end
local function is_active(pos)
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 = {
_attach = function(self, attached, attach_to)

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