2019-01-23 21:53:26 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2020-03-21 09:05:53 -04:00
|
|
|
local math, minetest, nodecore, pairs
|
|
|
|
= math, minetest, nodecore, pairs
|
2020-06-20 23:48:29 -04:00
|
|
|
local math_floor
|
|
|
|
= math.floor
|
2019-01-23 21:53:26 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
minetest.register_ore({
|
|
|
|
name = "gravel",
|
|
|
|
ore_type = "blob",
|
|
|
|
ore = modname .. ":gravel",
|
|
|
|
wherein = modname .. ":stone",
|
|
|
|
clust_size = 5,
|
2019-01-23 22:47:00 -05:00
|
|
|
clust_scarcity = 8 * 8 * 8,
|
2019-01-23 21:53:26 -05:00
|
|
|
random_factor = 0,
|
|
|
|
noise_params = {
|
2019-08-27 19:14:51 -04:00
|
|
|
offset = 0,
|
|
|
|
scale = 3,
|
2020-02-27 19:11:12 -05:00
|
|
|
spread = {x = 10, y = 25, z = 10},
|
2019-08-27 19:14:51 -04:00
|
|
|
seed = 34654,
|
2019-01-23 21:53:26 -05:00
|
|
|
octaves = 3,
|
|
|
|
persist = 0.5,
|
|
|
|
flags = "eased",
|
|
|
|
},
|
2019-08-27 19:14:51 -04:00
|
|
|
noise_threshold = 1.2
|
2019-01-23 21:53:26 -05:00
|
|
|
})
|
2020-03-21 09:05:53 -04:00
|
|
|
|
|
|
|
local c_air = minetest.get_content_id("air")
|
|
|
|
local c_stones = {}
|
|
|
|
for _, n in pairs(minetest.registered_nodes[modname .. ":stone"].strata) do
|
|
|
|
c_stones[minetest.get_content_id(n)] = true
|
|
|
|
end
|
|
|
|
local function regspring(label, node, rarity)
|
|
|
|
local c_node = minetest.get_content_id(node)
|
|
|
|
nodecore.register_mapgen_shared({
|
|
|
|
label = label,
|
2020-06-20 23:48:29 -04:00
|
|
|
func = function(minp, maxp, area, data, _, _, _, rng)
|
|
|
|
local rawqty = rng() * (maxp.x - minp.x + 1)
|
2020-03-21 09:05:53 -04:00
|
|
|
* (maxp.z - minp.z + 1) * (maxp.y - minp.y + 1) / rarity
|
|
|
|
local qty = math_floor(rawqty)
|
2020-06-20 23:48:29 -04:00
|
|
|
if rng() < (rawqty - qty) then qty = qty + 1 end
|
2020-03-21 09:05:53 -04:00
|
|
|
|
|
|
|
for _ = 1, qty do
|
2020-06-28 20:24:15 -04:00
|
|
|
local x = rng(minp.x + 1, maxp.x - 1)
|
|
|
|
local y = rng(minp.y + 1, maxp.y - 1)
|
|
|
|
local z = rng(minp.z + 1, maxp.z - 1)
|
|
|
|
local idx = area:index(x, y, z)
|
|
|
|
if c_stones[idx]
|
|
|
|
and (data[idx - 1] == c_air
|
|
|
|
or data[idx + 1] == c_air
|
|
|
|
or data[idx - area.ystride] == c_air
|
|
|
|
or data[idx + area.ystride] == c_air
|
|
|
|
or data[idx - area.zstride] == c_air
|
|
|
|
or data[idx + area.zstride] == c_air)
|
2020-03-21 09:05:53 -04:00
|
|
|
then data[area:index(x, y, z)] = c_node end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
local baserarity = 32 * 32 * 32
|
|
|
|
regspring("water spring", modname .. ":water_source", baserarity)
|
|
|
|
regspring("lava spring", modname .. ":lava_source", baserarity * 8)
|