Skip to content

Commit

Permalink
working caves
Browse files Browse the repository at this point in the history
  • Loading branch information
naturefreshmilk committed Sep 5, 2019
1 parent 26d3070 commit bce56ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
21 changes: 0 additions & 21 deletions decorations.lua
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion depends.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ vacuum?
bedrock?
skybox?
gravity_manager?
bamboo?
15 changes: 10 additions & 5 deletions mapgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,17 @@ 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
for y=minp.y,maxp.y do
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))

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bce56ee

Please sign in to comment.