forked from mtcontrib/pipeworks
allow pipeworks to skip server steps when moving entities around.
This commit is contained in:
parent
3a77d1dd8e
commit
0639bb9706
|
@ -52,12 +52,8 @@ local function get_blockpos(pos)
|
|||
end
|
||||
|
||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
||||
local handle_active_blocks_step = 2
|
||||
local handle_active_blocks_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
handle_active_blocks_timer = handle_active_blocks_timer + dtime
|
||||
if handle_active_blocks_timer >= handle_active_blocks_step then
|
||||
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
|
||||
|
||||
local move_entities_globalstep_part1 = function(dtime)
|
||||
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
||||
local new_active_blocks = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
|
@ -77,7 +73,6 @@ minetest.register_globalstep(function(dtime)
|
|||
active_blocks = new_active_blocks
|
||||
-- todo: callbacks on block load/unload
|
||||
end
|
||||
end)
|
||||
|
||||
local function is_active(pos)
|
||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
|
@ -309,7 +304,7 @@ function luaentity.get_objects_inside_radius(pos, radius)
|
|||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local move_entities_globalstep_part2 = function(dtime)
|
||||
if not luaentity.entities then
|
||||
luaentity.entities = read_entities()
|
||||
end
|
||||
|
@ -348,4 +343,16 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local handle_active_blocks_step = 0.2
|
||||
local handle_active_blocks_timer = 0.1
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
handle_active_blocks_timer = handle_active_blocks_timer + dtime
|
||||
if handle_active_blocks_timer >= handle_active_blocks_step then
|
||||
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
|
||||
move_entities_globalstep_part1(dtime)
|
||||
move_entities_globalstep_part2(dtime)
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue
Block a user