Work on schematic issues.
parent
a380aad83b
commit
9928eb7be2
347
mapgen.lua
347
mapgen.lua
|
@ -182,15 +182,17 @@ local function place_schematic(pos, schem, center)
|
||||||
local ivm = a:index(pos.x + x, pos.y, pos.z + z)
|
local ivm = a:index(pos.x + x, pos.y, pos.z + z)
|
||||||
local isch = z1 * schem.size.y * schem.size.x + x1 + 1
|
local isch = z1 * schem.size.y * schem.size.x + x1 + 1
|
||||||
for y = 0, schem.size.y - 1 do
|
for y = 0, schem.size.y - 1 do
|
||||||
local fdy = (pos.y + y) % fcsize.y
|
if pos.y + y < maxp.y + 16 and pos.y + y > minp.y - 16 then
|
||||||
if math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) > bevel then
|
local fdy = (pos.y + y) % fcsize.y
|
||||||
if yslice[y] or 255 >= math.random(255) then
|
if math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) > bevel then
|
||||||
local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
if yslice[y] or 255 >= math.random(255) then
|
||||||
if prob >= math.random(255) and schem.data[isch].name ~= "air" then
|
local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
||||||
data[ivm] = node[schem.data[isch].name]
|
if prob >= math.random(255) and schem.data[isch].name ~= "air" then
|
||||||
|
data[ivm] = node[schem.data[isch].name]
|
||||||
|
end
|
||||||
|
local param2 = schem.data[isch].param2 or 0
|
||||||
|
p2data[ivm] = param2
|
||||||
end
|
end
|
||||||
local param2 = schem.data[isch].param2 or 0
|
|
||||||
p2data[ivm] = param2
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -344,15 +346,15 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
if (fdy == half_pod.y and fdx == half_pod.x) or (fdy == half_pod.y and fdz == half_pod.z) then
|
if (fdy == half_pod.y and fdx == half_pod.x) or (fdy == half_pod.y and fdz == half_pod.z) then
|
||||||
data[ivm] = node['loud_walking:scrith']
|
data[ivm] = node['loud_walking:scrith']
|
||||||
else
|
else
|
||||||
data[ivm] = node['air']
|
--data[ivm] = node['air']
|
||||||
end
|
end
|
||||||
elseif math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel then
|
elseif math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel then
|
||||||
data[ivm] = node['air']
|
--data[ivm] = node['air']
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
in_cave = false
|
in_cave = false
|
||||||
elseif (fdx == 0 or fdx == pod_size.x - 1) or (fdz == 0 or fdz == pod_size.z - 1) or (fdy == 0 or fdy == pod_size.y - 1) or math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel + 1 then
|
elseif (fdx == 0 or fdx == pod_size.x - 1) or (fdz == 0 or fdz == pod_size.z - 1) or (fdy == 0 or fdy == pod_size.y - 1) or math.min(fdx, pod_size.x - fdx) + math.min(fdy, pod_size.y - fdy) + math.min(fdz, pod_size.z - fdz) < bevel + 1 then
|
||||||
if math_abs(fdy - half_pod.y - 2) < 2 and (fdz == half_pod.z or fdx == half_pod.x) then
|
if math_abs(fdy - half_pod.y - 2) < 2 and (fdz == half_pod.z or fdx == half_pod.x) then
|
||||||
data[ivm] = node["air"]
|
--data[ivm] = node["air"]
|
||||||
else
|
else
|
||||||
if biome == "control" then
|
if biome == "control" then
|
||||||
data[ivm] = node[glass[3]]
|
data[ivm] = node[glass[3]]
|
||||||
|
@ -373,7 +375,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
elseif biome == "control" and fdy % 5 == 0 then
|
elseif biome == "control" and fdy % 5 == 0 then
|
||||||
data[ivm] = node["loud_walking:control_floor"]
|
data[ivm] = node["loud_walking:control_floor"]
|
||||||
elseif biome == "control" and (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then
|
elseif biome == "control" and (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then
|
||||||
data[ivm] = node["air"]
|
--data[ivm] = node["air"]
|
||||||
elseif biome == "control" and ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - 12) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - 12) % room_size > 3)) then
|
elseif biome == "control" and ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - 12) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - 12) % room_size > 3)) then
|
||||||
data[ivm] = node["loud_walking:control_wall"]
|
data[ivm] = node["loud_walking:control_wall"]
|
||||||
elseif biome == "control" then
|
elseif biome == "control" then
|
||||||
|
@ -402,7 +404,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
data[ivm] = node[node_water]
|
data[ivm] = node[node_water]
|
||||||
in_cave = false
|
in_cave = false
|
||||||
elseif fdy > height + ground then
|
elseif fdy > height + ground then
|
||||||
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(fdy / (half_pod.y * 0.2))) then
|
elseif cave[index3d] ^ 2 > (biome == "underground" and 0.5 or 1.3 - math.sin(fdy / (half_pod.y * 0.2))) then
|
||||||
cave_height = cave_height + 1
|
cave_height = cave_height + 1
|
||||||
|
@ -432,7 +434,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
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"]
|
||||||
else
|
else
|
||||||
data[ivm] = node["air"]
|
--data[ivm] = node["air"]
|
||||||
end
|
end
|
||||||
in_cave = true
|
in_cave = true
|
||||||
--lightmap[ivm] = 0
|
--lightmap[ivm] = 0
|
||||||
|
@ -487,15 +489,16 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
last_py = nil
|
last_py = nil
|
||||||
for y = minp.y, maxp.y do
|
for y = minp.y, maxp.y do
|
||||||
local fdy = y % fcsize.y
|
|
||||||
local py = math_floor(y / fcsize.y)
|
|
||||||
if fdz % 5 == 0 and fdx % 5 == 0 then
|
if fdz % 5 == 0 and fdx % 5 == 0 then
|
||||||
local fdy = y % fcsize.y
|
local fdy = y % fcsize.y
|
||||||
|
local py = math_floor(y / fcsize.y)
|
||||||
local pod = fdz < pod_size.z and fdx < pod_size.x and fdy < pod_size.y
|
local pod = fdz < pod_size.z and fdx < pod_size.x and fdy < pod_size.y
|
||||||
if py ~= last_py or px ~= last_px or pz ~= last_pz then
|
if py ~= last_py or px ~= last_px or pz ~= last_pz then
|
||||||
biome, cave_lining = get_biome(x, y, z)
|
biome, cave_lining = get_biome(x, y, z)
|
||||||
|
ocean = string.find(biome, "ocean") and true or false
|
||||||
|
swamp = string.find(biome, "swamp") and true or false
|
||||||
|
node_top = biomes[biome].node_top or "default:dirt_with_grass"
|
||||||
end
|
end
|
||||||
local ocean = string.find(biome, "ocean") and true or false
|
|
||||||
if py ~= last_py then
|
if py ~= last_py then
|
||||||
height = get_height(fdx, fdz, y, index, heights, biomes[biome].terrain_scale, ocean)
|
height = get_height(fdx, fdz, y, index, heights, biomes[biome].terrain_scale, ocean)
|
||||||
end
|
end
|
||||||
|
@ -503,8 +506,6 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
if biome ~= 'control' and pod and fdy == height + ground and biomes[biome].special_tree_prob and math.random(biomes[biome].special_tree_prob) == 1 then
|
if biome ~= 'control' and pod and fdy == height + ground and biomes[biome].special_tree_prob and math.random(biomes[biome].special_tree_prob) == 1 then
|
||||||
local rx = x + math.random(5) - 1
|
local rx = x + math.random(5) - 1
|
||||||
local rz = z + math.random(5) - 1
|
local rz = z + math.random(5) - 1
|
||||||
local swamp = string.find(biome, "swamp") and true or false
|
|
||||||
local node_top = biomes[biome].node_top or "default:dirt_with_grass"
|
|
||||||
|
|
||||||
local ivm = a:index(rx, y, rz)
|
local ivm = a:index(rx, y, rz)
|
||||||
if (swamp or data[ivm + a.ystride] ~= node["default:water_source"]) and (data[ivm] == node[node_top]) then
|
if (swamp or data[ivm + a.ystride] ~= node["default:water_source"]) and (data[ivm] == node[node_top]) then
|
||||||
|
@ -597,314 +598,6 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function generate_old(p_minp, p_maxp, seed)
|
|
||||||
minp, maxp = p_minp, p_maxp
|
|
||||||
vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
vm:get_data(data)
|
|
||||||
--p2data = vm:get_param2_data()
|
|
||||||
a = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
|
||||||
csize = vector.add(vector.subtract(maxp, minp), 1)
|
|
||||||
|
|
||||||
-- Deal with memory issues. This, of course, is supposed to be automatic.
|
|
||||||
local mem = math_floor(collectgarbage("count")/1024)
|
|
||||||
if mem > 300 then
|
|
||||||
print("Loud Walking: Manually collecting garbage...")
|
|
||||||
collectgarbage("collect")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- use the same seed (based on perlin noise).
|
|
||||||
local seed_noise = minetest.get_perlin({offset = 0, scale = 32768,
|
|
||||||
seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2,
|
|
||||||
persist = 0.4, lacunarity = 2})
|
|
||||||
math.randomseed(seed_noise:get2d({x=minp.x, y=minp.z}))
|
|
||||||
|
|
||||||
-- Keep this first after seeding!
|
|
||||||
local px = math_floor((minp.x + 32) / csize.x)
|
|
||||||
local pz = math_floor((minp.z + 32) / csize.z)
|
|
||||||
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
|
|
||||||
|
|
||||||
vm:set_lighting({day = 15, night = (biome == "control" and 15 or 0)}, minp, maxp)
|
|
||||||
lightmap = vm:get_light_data()
|
|
||||||
|
|
||||||
local node_top = biomes[biome].node_top or "default:dirt_with_grass"
|
|
||||||
local node_filler = biomes[biome].node_filler or "default:dirt"
|
|
||||||
local node_water_top = biomes[biome].node_water_top or "default:water_source"
|
|
||||||
local node_water = biomes[biome].node_water or "default:water_source"
|
|
||||||
local depth_top = biomes[biome].depth_top or 1
|
|
||||||
local depth_water_top = biomes[biome].node_water_top or 1
|
|
||||||
local depth_filler = biomes[biome].depth_filler or 1
|
|
||||||
local node_stone = biomes[biome].node_stone or "default:stone"
|
|
||||||
local ocean = string.find(biome, "ocean") and true or false
|
|
||||||
local swamp = string.find(biome, "swamp") and true or false
|
|
||||||
local beach = string.find(biome, "beach") and true or false
|
|
||||||
local dunes = string.find(biome, "dunes") and true or false
|
|
||||||
local half = {x=math_floor(csize.x / 2 + 0.5), y=math_floor(csize.y / 2 + 0.5), z=math_floor(csize.z / 2 + 0.5)}
|
|
||||||
local ground = half.y
|
|
||||||
|
|
||||||
beach = beach or dunes
|
|
||||||
if ocean then
|
|
||||||
ground = ground - 15
|
|
||||||
elseif swamp or beach then
|
|
||||||
ground = ground - 3
|
|
||||||
end
|
|
||||||
|
|
||||||
terrain = minetest.get_perlin_map(terrain_noise, csize):get2dMap_flat(minp)
|
|
||||||
cave = minetest.get_perlin_map(cave_noise, csize):get3dMap_flat(minp)
|
|
||||||
cloud = minetest.get_perlin_map(cloud_noise, csize):get2dMap_flat(minp)
|
|
||||||
|
|
||||||
local pod = is_pod(minp.x, minp.y, minp.z)
|
|
||||||
local connection = connection(minp.x, minp.y, minp.z)
|
|
||||||
|
|
||||||
local index = 0
|
|
||||||
local index3d = 0
|
|
||||||
for z = minp.z, maxp.z do
|
|
||||||
local dz = z - minp.z
|
|
||||||
for x = minp.x, maxp.x do
|
|
||||||
index = index + 1
|
|
||||||
local dx = x - minp.x
|
|
||||||
index3d = dz * csize.y * csize.x + dx + 1
|
|
||||||
local ivm = a:index(x, minp.y, z)
|
|
||||||
|
|
||||||
local terr = get_height(dx, dz, biomes[biome].terrain_scale, ocean, index)
|
|
||||||
local in_cave = false
|
|
||||||
if biome == "underground" then
|
|
||||||
terr = half.y - 5
|
|
||||||
end
|
|
||||||
|
|
||||||
local cave_height = 0
|
|
||||||
for y = minp.y, maxp.y do
|
|
||||||
local dy = y - minp.y
|
|
||||||
if pod then
|
|
||||||
if biome == "control" and math_abs(dx - half.x) < 3 and math_abs(dz - half.z) < 3 then
|
|
||||||
data[ivm] = node["loud_walking:air_ladder"]
|
|
||||||
elseif math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) < bevel then
|
|
||||||
data[ivm] = node["air"]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
in_cave = false
|
|
||||||
elseif (dx == 0 or dx == csize.x - 1) or (dz == 0 or dz == csize.z - 1) or (dy == 0 or dy == csize.y - 1) or math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) < bevel + 1 then
|
|
||||||
if math_abs(dy - half.y - 2) < 2 and (dz == half.z or dx == half.x) then
|
|
||||||
data[ivm] = node["air"]
|
|
||||||
else
|
|
||||||
if biome == "control" then
|
|
||||||
data[ivm] = node[glass[3]]
|
|
||||||
elseif dy < half.y then
|
|
||||||
data[ivm] = node["loud_walking:scrith"]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
elseif biome == "underground" then
|
|
||||||
data[ivm] = node["loud_walking:scrith"]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
elseif dy == csize.y - 1 then
|
|
||||||
data[ivm] = node[glass[cloud[index] < cloud_i and 1 or 2]]
|
|
||||||
else
|
|
||||||
data[ivm] = node[glass[1]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
in_cave = false
|
|
||||||
elseif biome == "control" and dy % 5 == 0 then
|
|
||||||
data[ivm] = node["loud_walking:control_floor"]
|
|
||||||
elseif biome == "control" and (math_abs(dx - half.x) < 3 or math_abs(dz - half.z) < 3) then
|
|
||||||
data[ivm] = node["air"]
|
|
||||||
elseif biome == "control" and ((math_abs(dx - half.x) % 20 == 3 and (math_abs(dz - half.z) - 12) % 20 > 3) or (math_abs(dz - half.z) % 20 == 3 and (math_abs(dx - half.x) - 12) % 20 > 3)) then
|
|
||||||
data[ivm] = node["loud_walking:control_wall"]
|
|
||||||
elseif biome == "control" then
|
|
||||||
--
|
|
||||||
elseif (((dx == 35 or dx == 45) and dz >= 35 and dz <= 45) or ((dz == 35 or dz == 45) and dx >= 35 and dx <= 45)) and dx ~= 40 and dz ~= 40 and dy == csize.y - 2 then
|
|
||||||
data[ivm] = node["loud_walking:controls"]
|
|
||||||
elseif (((dx == 35 or dx == 45) and dz >= 35 and dz <= 45) or ((dz == 35 or dz == 45) and dx >= 35 and dx <= 45)) and dx ~= 40 and dz ~= 40 and dy > csize.y - 5 then
|
|
||||||
data[ivm] = node[glass[3]]
|
|
||||||
elseif dz >= 35 and dz <= 45 and dx >= 35 and dx <= 45 and dy == csize.y - 5 then
|
|
||||||
data[ivm] = node[glass[3]]
|
|
||||||
elseif not in_cave and (ocean or swamp or beach) and dy > terr + ground and dy <= half.y and dy == terr + ground + 1 then
|
|
||||||
-- ** water decorations **
|
|
||||||
--local deco = get_decoration(biome)
|
|
||||||
--if deco then
|
|
||||||
-- data[ivm] = node[deco]
|
|
||||||
--end
|
|
||||||
elseif not in_cave and dy == terr + ground + 1 then
|
|
||||||
local deco = get_decoration(biome)
|
|
||||||
if deco then
|
|
||||||
data[ivm] = node[deco]
|
|
||||||
end
|
|
||||||
elseif (ocean or swamp or beach) and dy > terr + ground and dy <= half.y and dy >= half.y - depth_water_top then
|
|
||||||
data[ivm] = node[node_water_top]
|
|
||||||
in_cave = false
|
|
||||||
elseif (ocean or swamp or beach) and dy > terr + ground and dy <= half.y then
|
|
||||||
data[ivm] = node[node_water]
|
|
||||||
in_cave = false
|
|
||||||
elseif dy > terr + ground then
|
|
||||||
data[ivm] = node["air"]
|
|
||||||
in_cave = false
|
|
||||||
elseif cave[index3d] ^ 2 > (biome == "underground" and 0.5 or 1.3 - math.sin(dy / (half.y * 0.2))) then
|
|
||||||
cave_height = cave_height + 1
|
|
||||||
if terr + ground >= dy and not in_cave and dy > terr + ground - 10 then
|
|
||||||
data[ivm] = node[node_top]
|
|
||||||
elseif dy == 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"]
|
|
||||||
elseif ocean or swamp or beach then
|
|
||||||
data[ivm] = node[node_filler]
|
|
||||||
end
|
|
||||||
elseif (ocean or swamp or beach) and not in_cave and node_stone == "default:stone" and dy < half.y and math.random(20) == 1 then
|
|
||||||
data[ivm] = node["loud_walking:glowing_fungal_stone"]
|
|
||||||
elseif (ocean or swamp or beach) and dy < half.y then
|
|
||||||
data[ivm] = node[node_water]
|
|
||||||
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 - 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]
|
|
||||||
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 - a.ystride] = node["loud_walking:giant_mushroom_stem"]
|
|
||||||
data[ivm - 2 * a.ystride] = node[node_filler]
|
|
||||||
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"]
|
|
||||||
elseif not in_cave and node_stone == "default:ice" and math.random(10) == 1 then
|
|
||||||
data[ivm] = node["loud_walking:icicle_up"]
|
|
||||||
else
|
|
||||||
data[ivm] = node["air"]
|
|
||||||
end
|
|
||||||
in_cave = true
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
elseif cave_lining and cave[index3d] ^ 2 > (biome == "underground" and 0.4 or 1.2 - math.sin(dy / (half.y * 0.2))) then
|
|
||||||
data[ivm] = node[cave_lining]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
elseif dy > terr + ground - depth_top then
|
|
||||||
data[ivm] = node[node_top]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
in_cave = false
|
|
||||||
elseif dy > terr + ground - depth_filler - depth_top then
|
|
||||||
data[ivm] = node[node_filler]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
in_cave = false
|
|
||||||
else
|
|
||||||
data[ivm] = node[node_stone]
|
|
||||||
if in_cave and node_stone == "default:stone" and math.random(20) == 1 then
|
|
||||||
data[ivm] = node["loud_walking:glowing_fungal_stone"]
|
|
||||||
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"]
|
|
||||||
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"]
|
|
||||||
end
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
in_cave = false
|
|
||||||
end
|
|
||||||
elseif biome == "control" and math_abs(dx - half.x) < 3 and math_abs(dz - half.z) < 3 then
|
|
||||||
data[ivm] = node["loud_walking:air_ladder"]
|
|
||||||
elseif connection and dy == half.y and ((dx == half.x and connection % 4 == 0) or (dz == half.z and connection % 2 == 1)) then
|
|
||||||
data[ivm] = node["loud_walking:scrith"]
|
|
||||||
lightmap[ivm] = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if not in_cave then
|
|
||||||
cave_height = 0
|
|
||||||
end
|
|
||||||
ivm = ivm + a.ystride
|
|
||||||
index3d = index3d + csize.x
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if pod then
|
|
||||||
for dz = 0, 75, 5 do
|
|
||||||
for dx = 0, 75, 5 do
|
|
||||||
if biomes[biome].special_tree_prob and math.random(biomes[biome].special_tree_prob) == 1 then
|
|
||||||
local x = minp.x + dx + math.random(5) - 1
|
|
||||||
local z = minp.z + dz + math.random(5) - 1
|
|
||||||
local y = minp.y + get_height(x - minp.x, z - minp.z, biomes[biome].terrain_scale, ocean) + ground
|
|
||||||
|
|
||||||
local ivm = a:index(x, y, z)
|
|
||||||
if y >= minp.y and y <= maxp.y and (swamp or data[ivm + a.ystride] ~= node["default:water_source"]) and (data[ivm] == node[node_top]) then
|
|
||||||
if biomes[biome].special_trees then
|
|
||||||
local tree_type = biomes[biome].special_trees[math.random(#biomes[biome].special_trees)]
|
|
||||||
if tree_type and loud_walking.schematics then
|
|
||||||
local schem = loud_walking.schematics[tree_type][math.random(#loud_walking.schematics[tree_type])]
|
|
||||||
local pos = {x=x, y=y, z=z}
|
|
||||||
-- The minetest schematic functions don't seem very accurate.
|
|
||||||
place_schematic(pos, schem, true)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- regular schematics?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if pod and biome == "control" then
|
|
||||||
for dy = 0, 15 do
|
|
||||||
for dz = 0, 1 do
|
|
||||||
for dx = 0, 1 do
|
|
||||||
local x1 = minp.x + dx * 26 + 17
|
|
||||||
local z1 = minp.z + dz * 26 + 17
|
|
||||||
local y1 = minp.y + dy * 5
|
|
||||||
|
|
||||||
local sr = math.random(6)
|
|
||||||
for z = 0, 20 do
|
|
||||||
local ivm = a:index(x1, y1, z1 + z)
|
|
||||||
for x = 0, 20 do
|
|
||||||
if sr == 1 then
|
|
||||||
if dy > 0 then
|
|
||||||
if data[ivm] == node["loud_walking:control_floor_alert_down"] then
|
|
||||||
data[ivm] = node["loud_walking:control_floor_alert_both"]
|
|
||||||
else
|
|
||||||
data[ivm] = node["loud_walking:control_floor_alert_up"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if dy < 15 then
|
|
||||||
data[ivm + a.ystride * 5] = node["loud_walking:control_floor_alert_down"]
|
|
||||||
end
|
|
||||||
elseif sr == 2 then
|
|
||||||
if x > 1 and x < 19 and z > 1 and z < 19 and (z - 2) % 4 ~= 0 and (x - 2) % 4 ~= 0 then
|
|
||||||
for y = 1, 4 do
|
|
||||||
data[ivm + y * a.ystride] = node["loud_walking:air_ladder"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif sr == 3 then
|
|
||||||
if dy > 0 and data[ivm] ~= node["loud_walking:control_floor_alert_down"] and x > 0 and z > 0 and x < 20 and z < 20 then
|
|
||||||
data[ivm] = node["loud_walking:control_floor_growth"]
|
|
||||||
local sr2 = math.random(20)
|
|
||||||
if sr2 == 1 then
|
|
||||||
data[ivm + a.ystride] = node["loud_walking:control_plant_1"]
|
|
||||||
elseif sr2 == 2 then
|
|
||||||
data[ivm + a.ystride] = node["loud_walking:control_plant_2"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif sr == 4 then
|
|
||||||
if dy < 15 and (x > 0 and x < 20 and z > 0 and z < 20) and (((x == 1 or x == 19) and math_abs(z - 10) > 3) or ((z == 1 or z == 19) and math_abs(x - 10) > 3)) then
|
|
||||||
data[ivm + 3 * a.ystride] = node["loud_walking:controls"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ivm = ivm + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vm:set_data(data)
|
|
||||||
minetest.generate_ores(vm, minp, maxp)
|
|
||||||
--minetest.generate_decorations(vm, minp, maxp)
|
|
||||||
--vm:set_param2_data(p2data)
|
|
||||||
--vm:set_lighting({day = 15, night = 0})
|
|
||||||
if pod then
|
|
||||||
vm:set_light_data(lightmap)
|
|
||||||
end
|
|
||||||
vm:update_liquids()
|
|
||||||
vm:calc_lighting(minp, maxp, false)
|
|
||||||
vm:write_to_map()
|
|
||||||
|
|
||||||
vm, a, heightmap, biomemap = nil, nil, nil, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function pgenerate(...)
|
local function pgenerate(...)
|
||||||
--local status, err = pcall(generate, ...)
|
--local status, err = pcall(generate, ...)
|
||||||
local status, err = true
|
local status, err = true
|
||||||
|
|
Loading…
Reference in New Issue