init.lua 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. local modname = minetest.get_current_modname()
  2. local S = minetest.get_translator(modname)
  3. local modpath = minetest.get_modpath(modname)
  4. _G[modname] = {}
  5. local ore_noise_params = {}
  6. local range_ranges = {}
  7. _G[modname].register_prospectable = function(name, oredef)
  8. ore_noise_params[name] = oredef.noise_params
  9. range_ranges[name] = {min = oredef.y_min or -31000, max = oredef.y_max or 31000}
  10. end
  11. local ore_noise_objects
  12. minetest.register_on_joinplayer(function()
  13. if not ore_noise_objects
  14. then
  15. ore_noise_objects = {}
  16. for k, v in pairs(ore_noise_params)
  17. do
  18. ore_noise_objects[k] = minetest.get_perlin(v)
  19. end
  20. end
  21. end)
  22. _G[modname].get_prospect = function(pos)
  23. local prospect = {}
  24. for k, v in pairs(ore_noise_objects)
  25. do
  26. local range = range_ranges[k]
  27. if pos.y > range.min and pos.y < range.max
  28. then
  29. prospect[k] = v:get_3d(pos)
  30. print(prospect[k])
  31. end
  32. end
  33. return prospect
  34. end
  35. dofile(modpath .. "/pick.lua")