12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- local modname = minetest.get_current_modname()
- local S = minetest.get_translator(modname)
- local modpath = minetest.get_modpath(modname)
- _G[modname] = {}
- local ore_noise_params = {}
- local range_ranges = {}
- _G[modname].register_prospectable = function(name, oredef)
- ore_noise_params[name] = oredef.noise_params
- range_ranges[name] = {min = oredef.y_min or -31000, max = oredef.y_max or 31000}
- end
- local ore_noise_objects
- minetest.register_on_joinplayer(function()
- if not ore_noise_objects
- then
- ore_noise_objects = {}
- for k, v in pairs(ore_noise_params)
- do
- ore_noise_objects[k] = minetest.get_perlin(v)
- end
- end
- end)
- _G[modname].get_prospect = function(pos)
- local prospect = {}
- for k, v in pairs(ore_noise_objects)
- do
- local range = range_ranges[k]
- if pos.y > range.min and pos.y < range.max
- then
- prospect[k] = v:get_3d(pos)
- print(prospect[k])
- end
- end
- return prospect
- end
- dofile(modpath .. "/pick.lua")
|