diff --git a/init.lua b/init.lua index 3b9aa4c..2eb0b66 100644 --- a/init.lua +++ b/init.lua @@ -76,6 +76,9 @@ local rr = tonumber(minetest.settings:get("biome_lib_queue_run_ratio")) or -100 biome_lib.queue_run_ratio = 100 - rr biome_lib.entries_per_step = math.max(-rr, 1) +-- timer runs in microseconds, but I want the user to supply a time in seconds +biome_lib.block_timeout = (tonumber(minetest.settings:get("biome_lib_block_timeout")) or 300) * 1000000 + local time_speed = tonumber(minetest.settings:get("time_speed")) biome_lib.plantlife_seed_diff = 329 -- needs to be global so other mods can see it @@ -477,10 +480,12 @@ function biome_lib.generate_block(shutting_down) local pos_hash = minetest.hash_node_position(minp) if not biome_lib.pos_hash then -- we need to read the maplock and get the surfaces list + local now = minetest.get_us_time() biome_lib.pos_hash = {} minetest.load_area(minp) if not confirm_block_surroundings(minp) - and not shutting_down then -- if any neighbors appear not to be loaded, skip this block for now + and not shutting_down + and (blocklog[1][4] + biome_lib.block_timeout) > now then -- if any neighbors appear not to be loaded and the block hasn't expired yet, defer it if biome_lib.run_block_recheck_list then biome_lib.block_log[#biome_lib.block_log + 1] = table.copy(biome_lib.block_recheck_list[1]) diff --git a/search_functions.lua b/search_functions.lua index 635842f..118e121 100644 --- a/search_functions.lua +++ b/search_functions.lua @@ -56,6 +56,7 @@ end -- split into individual mapblocks to reduce lag minetest.register_on_generated(function(minp, maxp, blockseed) + local timestamp = minetest.get_us_time() for x = 0, 4 do local minx = minp.x + x*16 for y = 0, 4 do @@ -65,8 +66,8 @@ minetest.register_on_generated(function(minp, maxp, blockseed) local bmin = {x=minx, y=miny, z=minz} local bmax = {x=minx + 15, y=miny + 15, z=minz + 15} - biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, true } - biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, false } + biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, true, timestamp } + biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, false, timestamp } end end end