Advertisement
Guest User

Untitled

a guest
Aug 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. -- "Record" the chunks being generated by the core mapgen
  2.  
  3. minetest.register_on_generated(function(minp, maxp, blockseed)
  4.         biome_lib.blocklist_aircheck[#biome_lib.blocklist_aircheck + 1] = { minp, maxp }
  5. end)
  6.  
  7. minetest.register_on_generated(function(minp, maxp, blockseed)
  8.         biome_lib.blocklist_no_aircheck[#biome_lib.blocklist_no_aircheck + 1] = { minp, maxp }
  9. end)
  10.  
  11. -- "Play" them back, populating them with new stuff in the process
  12.  
  13. minetest.register_globalstep(function(dtime)
  14.         if dtime < 0.2 and    -- don't attempt to populate if lag is already too high
  15.           (#biome_lib.blocklist_aircheck > 0 or #biome_lib.blocklist_no_aircheck > 0) then
  16.                 biome_lib.globalstep_start_time = minetest.get_us_time()
  17.                 biome_lib.globalstep_runtime = 0
  18.                 while (#biome_lib.blocklist_aircheck > 0 or #biome_lib.blocklist_no_aircheck > 0)
  19.                   and biome_lib.globalstep_runtime < 200000 do  -- 0.2 seconds, in uS.
  20.                         if #biome_lib.blocklist_aircheck > 0 then
  21.                                 biome_lib:generate_block_with_air_checking()
  22.                         end
  23.                         if #biome_lib.blocklist_no_aircheck > 0 then
  24.                                 biome_lib:generate_block_no_aircheck()
  25.                         end
  26.                         biome_lib.globalstep_runtime = minetest.get_us_time() - biome_lib.globalstep_start_time
  27.                 end
  28.         end
  29. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement