Add cave stones.
parent
cee178f3cc
commit
c67e7a17b7
39
mapgen.lua
39
mapgen.lua
|
@ -63,6 +63,17 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local cave_stones = {
|
||||||
|
"loud_walking:stone_with_moss",
|
||||||
|
"loud_walking:stone_with_lichen",
|
||||||
|
"loud_walking:stone_with_algae",
|
||||||
|
"loud_walking:stone_with_salt",
|
||||||
|
}
|
||||||
|
local mushroom_stones = {}
|
||||||
|
mushroom_stones[node("default:stone")] = true
|
||||||
|
mushroom_stones[node("loud_walking:stone_with_algae")] = true
|
||||||
|
mushroom_stones[node("loud_walking:stone_with_lichen")] = true
|
||||||
|
|
||||||
local function place_schematic(pos, schem, center)
|
local function place_schematic(pos, schem, center)
|
||||||
local yslice = {}
|
local yslice = {}
|
||||||
if schem.yslice_prob then
|
if schem.yslice_prob then
|
||||||
|
@ -178,7 +189,7 @@ local function get_biome(px, pz)
|
||||||
end
|
end
|
||||||
local biome = biome_names[rarity][math.random(#biome_names[rarity])]
|
local biome = biome_names[rarity][math.random(#biome_names[rarity])]
|
||||||
return biome
|
return biome
|
||||||
--return "glacier"
|
--return "sandstone_grassland"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_decoration(biome)
|
local function get_decoration(biome)
|
||||||
|
@ -227,6 +238,10 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
local px = math.floor((minp.x + 32) / csize.x)
|
local px = math.floor((minp.x + 32) / csize.x)
|
||||||
local pz = math.floor((minp.z + 32) / csize.z)
|
local pz = math.floor((minp.z + 32) / csize.z)
|
||||||
local biome = get_biome(px, pz)
|
local biome = get_biome(px, pz)
|
||||||
|
local cave_lining = cave_stones[math.random(#cave_stones)]
|
||||||
|
if math.random(3) == 1 then
|
||||||
|
cave_lining = nil
|
||||||
|
end
|
||||||
|
|
||||||
local node_top = biomes[biome].node_top or "default:dirt_with_grass"
|
local node_top = biomes[biome].node_top or "default:dirt_with_grass"
|
||||||
local node_filler = biomes[biome].node_filler or "default:dirt"
|
local node_filler = biomes[biome].node_filler or "default:dirt"
|
||||||
|
@ -281,7 +296,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
in_cave = false
|
in_cave = false
|
||||||
elseif math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) < bevel + 1 then
|
elseif math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) < bevel + 1 then
|
||||||
if dy < half then
|
if biome ~= "underground" and dy < half then
|
||||||
data[ivm] = node("loud_walking:scrith")
|
data[ivm] = node("loud_walking:scrith")
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
else
|
else
|
||||||
|
@ -293,7 +308,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
if math.abs(dy - half - 2) < 2 and (dz == half or dx == half) then
|
if math.abs(dy - half - 2) < 2 and (dz == half or dx == half) then
|
||||||
data[ivm] = node("air")
|
data[ivm] = node("air")
|
||||||
else
|
else
|
||||||
if dy < half then
|
if biome ~= "underground" and dy < half then
|
||||||
data[ivm] = node("loud_walking:scrith")
|
data[ivm] = node("loud_walking:scrith")
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
else
|
else
|
||||||
|
@ -331,10 +346,11 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
data[ivm] = node("air")
|
data[ivm] = node("air")
|
||||||
in_cave = false
|
in_cave = false
|
||||||
elseif cave[index3d] ^ 2 > (biome == "underground" and 0.5 or 1.3 - math.sin(dy / (half * 0.2))) then
|
elseif cave[index3d] ^ 2 > (biome == "underground" and 0.5 or 1.3 - math.sin(dy / (half * 0.2))) then
|
||||||
|
cave_height = cave_height + 1
|
||||||
if terr + ground >= dy and not in_cave and dy > terr + ground - 10 then
|
if terr + ground >= dy and not in_cave and dy > terr + ground - 10 then
|
||||||
data[ivm] = node(node_top)
|
data[ivm] = node(node_top)
|
||||||
elseif dy == 1 then
|
elseif dy == 1 then
|
||||||
if not ocean and not swamp and not beach and math.random(6) == 1 then
|
if not cave_lining and not ocean and not swamp and not beach and biome ~= "glacier" and math.random(6) == 1 then
|
||||||
data[ivm] = node("default:lava_source")
|
data[ivm] = node("default:lava_source")
|
||||||
elseif ocean or swamp or beach then
|
elseif ocean or swamp or beach then
|
||||||
data[ivm] = node(node_filler)
|
data[ivm] = node(node_filler)
|
||||||
|
@ -343,16 +359,16 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
data[ivm] = node("loud_walking:glowing_fungal_stone")
|
data[ivm] = node("loud_walking:glowing_fungal_stone")
|
||||||
elseif (ocean or swamp or beach) and dy < half then
|
elseif (ocean or swamp or beach) and dy < half then
|
||||||
data[ivm] = node(node_water)
|
data[ivm] = node(node_water)
|
||||||
elseif cave_height == 2 and node_filler == "default:dirt" and data[ivm - 3] == node(node_stone) and math.random(40) == 1 then
|
elseif cave_height == 3 and node_filler == "default:dirt" and mushroom_stones[data[ivm - 3 * a.ystride]] and math.random(40) == 1 then
|
||||||
data[ivm] = node("loud_walking:giant_mushroom_cap")
|
data[ivm] = node("loud_walking:giant_mushroom_cap")
|
||||||
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
|
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
|
||||||
data[ivm - 2 * a.ystride] = node("loud_walking:giant_mushroom_stem")
|
data[ivm - 2 * a.ystride] = node("loud_walking:giant_mushroom_stem")
|
||||||
data[ivm - 3 * a.ystride] = node(node_filler)
|
data[ivm - 3 * a.ystride] = node(node_filler)
|
||||||
elseif cave_height == 1 and node_filler == "default:dirt" and data[ivm - 3] == node(node_stone) and math.random(20) == 1 then
|
elseif cave_height == 2 and node_filler == "default:dirt" and mushroom_stones[data[ivm - 2 * a.ystride]] and math.random(20) == 1 then
|
||||||
data[ivm] = node("loud_walking:huge_mushroom_cap")
|
data[ivm] = node("loud_walking:huge_mushroom_cap")
|
||||||
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
|
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
|
||||||
data[ivm - 2 * a.ystride] = node(node_filler)
|
data[ivm - 2 * a.ystride] = node(node_filler)
|
||||||
elseif not in_cave and node_stone == "default:stone" and math.random(10) == 1 then
|
elseif not in_cave and node_stone == "default:stone" and not cave_lining and math.random(10) == 1 then
|
||||||
data[ivm] = node("loud_walking:stalagmite")
|
data[ivm] = node("loud_walking:stalagmite")
|
||||||
elseif not in_cave and node_stone == "default:ice" and math.random(10) == 1 then
|
elseif not in_cave and node_stone == "default:ice" and math.random(10) == 1 then
|
||||||
data[ivm] = node("loud_walking:icicle_up")
|
data[ivm] = node("loud_walking:icicle_up")
|
||||||
|
@ -361,6 +377,9 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
end
|
end
|
||||||
in_cave = true
|
in_cave = true
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
|
elseif cave_lining and cave[index3d] ^ 2 > (biome == "underground" and 0.4 or 1.2 - math.sin(dy / (half * 0.2))) then
|
||||||
|
data[ivm] = node(cave_lining)
|
||||||
|
lightmap[ivm] = 0
|
||||||
elseif dy > terr + ground - depth_top then
|
elseif dy > terr + ground - depth_top then
|
||||||
data[ivm] = node(node_top)
|
data[ivm] = node(node_top)
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
|
@ -375,7 +394,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
data[ivm] = node(node_stone)
|
data[ivm] = node(node_stone)
|
||||||
if in_cave and node_stone == "default:stone" and math.random(20) == 1 then
|
if in_cave and node_stone == "default:stone" and math.random(20) == 1 then
|
||||||
data[ivm] = node("loud_walking:glowing_fungal_stone")
|
data[ivm] = node("loud_walking:glowing_fungal_stone")
|
||||||
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:stone" and math.random(10) == 1 then
|
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:stone" and not cave_lining and math.random(10) == 1 then
|
||||||
data[ivm - a.ystride] = node("loud_walking:stalactite")
|
data[ivm - a.ystride] = node("loud_walking:stalactite")
|
||||||
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:ice" and math.random(10) == 1 then
|
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:ice" and math.random(10) == 1 then
|
||||||
data[ivm - a.ystride] = node("loud_walking:icicle_down")
|
data[ivm - a.ystride] = node("loud_walking:icicle_down")
|
||||||
|
@ -390,9 +409,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
write = true
|
write = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if in_cave then
|
if not in_cave then
|
||||||
cave_height = cave_height + 1
|
|
||||||
else
|
|
||||||
cave_height = 0
|
cave_height = 0
|
||||||
end
|
end
|
||||||
ivm = ivm + a.ystride
|
ivm = ivm + a.ystride
|
||||||
|
|
Loading…
Reference in New Issue