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
|
end
|
||||||
|
|
||||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
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
|
local move_entities_globalstep_part1 = function(dtime)
|
||||||
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 active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
||||||
local new_active_blocks = {}
|
local new_active_blocks = {}
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
@ -76,8 +72,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
active_blocks = new_active_blocks
|
active_blocks = new_active_blocks
|
||||||
-- todo: callbacks on block load/unload
|
-- todo: callbacks on block load/unload
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
|
|
||||||
local function is_active(pos)
|
local function is_active(pos)
|
||||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
local move_entities_globalstep_part2 = function(dtime)
|
||||||
if not luaentity.entities then
|
if not luaentity.entities then
|
||||||
luaentity.entities = read_entities()
|
luaentity.entities = read_entities()
|
||||||
end
|
end
|
||||||
@ -348,4 +343,16 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end
|
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)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user