working caves

master
Thomas Rudin 2019-09-05 21:02:28 +02:00
parent 26d3070b4e
commit bce56ee9f2
3 changed files with 10 additions and 27 deletions

View File

@ -1,23 +1,2 @@
-- decos for mars caves
if minetest.get_modpath("bamboo") then
minetest.register_decoration({
deco_type = "schematic",
place_on = {"default:dirt_with_grass"},
sidelen = 16,
noise_params = {
offset = 0.005,
scale = 0.001,
spread = {x = 240, y = 240, z = 240},
seed = 2776,
octaves = 3,
persist = 0.65
},
biomes = {"grassland"},
y_min = planet_mars.y_start,
y_max = planet_mars.y_start + planet_mars.y_height,
schematic = bamboo.bambootree,
flags = "place_center_x, place_center_z",
})
end

View File

@ -3,4 +3,3 @@ vacuum?
bedrock?
skybox?
gravity_manager?
bamboo?

View File

@ -155,7 +155,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end --x
end --z
perlin_index = 1
local perlin_index_2d = 1
local perlin_index_3d = 1
-- generate caves
for z=minp.z,maxp.z do
@ -163,8 +164,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
for x=minp.x,maxp.x do
local index = area:index(x,y,z)
local is_cave = math.abs(cave_perlin_map[perlin_index]) > 0.5
local is_cave_dirt = math.abs(cave_perlin_map[perlin_index]) < 0.55
local is_cave = math.abs(cave_perlin_map[perlin_index_3d]) > 0.5
local is_cave_dirt = math.abs(cave_perlin_map[perlin_index_3d]) < 0.55
local is_deep = y < (y_start + (y_height * 0.95))
@ -176,7 +177,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
if is_cave_dirt then
-- normalized factor from 0...1
local biome_perlin_factor = math.min(1, math.abs( biome_perlin_map[perlin_index] * 0.1 ) )
local biome_perlin_factor = math.min(1, math.abs( biome_perlin_map[perlin_index_2d] * 0.1 ) )
if biome_perlin_factor > 0.9 then
data[index] = c_base
@ -207,8 +208,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
perlin_index = perlin_index + 1
perlin_index_3d = perlin_index_3d + 1
perlin_index_2d = perlin_index_2d + 1
end --x
perlin_index_2d = z - minp.z + 1
end --y
end --z