init.lua 1021 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. if not minetest.global_exists("ww") then ww = {} end
  2. ww.modpath = minetest.get_modpath("ww")
  3. ww.worldpath = minetest.get_worldpath()
  4. function ww.on_generated(minp, maxp, blockseed)
  5. local mapgen = minetest.get_mapgen_object("gennotify")
  6. local data = (mapgen.custom and mapgen.custom["ww:mapgen_info"])
  7. if not data then return end
  8. -- This ugly hack is currently the best way I know of to make light correct
  9. -- after chunk generation.
  10. minetest.after(math.random(1, 100) / 50, function()
  11. local emin = vector.add(data.minp, {x=-16, y=-16, z=-16})
  12. local emax = vector.add(data.maxp, {x=16, y=16, z=16})
  13. mapfix.work(emin, emax)
  14. end)
  15. end
  16. if not ww.registered then
  17. minetest.set_gen_notify("custom", nil, {"ww:mapgen_info"})
  18. minetest.register_on_generated(function(...)
  19. ww.on_generated(...)
  20. end)
  21. -- Register the mapgen.
  22. minetest.register_mapgen_script(ww.modpath .. "/mapgen.lua")
  23. local c = "ww:core"
  24. local f = ww.modpath .. "/init.lua"
  25. reload.register_file(c, f, false)
  26. ww.registered = true
  27. end