Localize more functions.
This commit is contained in:
parent
16983356c8
commit
4a5950721e
1 changed files with 15 additions and 15 deletions
30
mapgen.lua
30
mapgen.lua
|
@ -61,7 +61,7 @@ for name, desc in pairs(minetest.registered_biomes) do
|
||||||
end
|
end
|
||||||
|
|
||||||
--local function place_schematic(pos, schem, center)
|
--local function place_schematic(pos, schem, center)
|
||||||
-- local rot = math.random(4) - 1
|
-- local rot = rand(4) - 1
|
||||||
-- local yslice = {}
|
-- local yslice = {}
|
||||||
-- if schem.yslice_prob then
|
-- if schem.yslice_prob then
|
||||||
-- for _, ys in pairs(schem.yslice_prob) do
|
-- for _, ys in pairs(schem.yslice_prob) do
|
||||||
|
@ -94,9 +94,9 @@ end
|
||||||
-- for y = 0, schem.size.y - 1 do
|
-- for y = 0, schem.size.y - 1 do
|
||||||
-- local dy = pos.y - minp.y + y
|
-- local dy = pos.y - minp.y + y
|
||||||
-- if math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) > bevel then
|
-- if math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) > bevel then
|
||||||
-- if yslice[y] or 255 >= math.random(255) then
|
-- if yslice[y] or 255 >= rand(255) then
|
||||||
-- local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
-- local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
||||||
-- if prob >= math.random(255) and schem.data[isch].name ~= "air" then
|
-- if prob >= rand(255) and schem.data[isch].name ~= "air" then
|
||||||
-- data[ivm] = node[schem.data[isch].name]
|
-- data[ivm] = node[schem.data[isch].name]
|
||||||
-- end
|
-- end
|
||||||
-- local param2 = schem.data[isch].param2 or 0
|
-- local param2 = schem.data[isch].param2 or 0
|
||||||
|
@ -117,7 +117,7 @@ end
|
||||||
-- if not deco.biomes or deco.biomes[biome] then
|
-- if not deco.biomes or deco.biomes[biome] then
|
||||||
-- local range = 1000
|
-- local range = 1000
|
||||||
-- if deco.deco_type == "simple" then
|
-- if deco.deco_type == "simple" then
|
||||||
-- if deco.fill_ratio and math.random(range) - 1 < deco.fill_ratio * 1000 then
|
-- if deco.fill_ratio and rand(range) - 1 < deco.fill_ratio * 1000 then
|
||||||
-- return deco.decoration
|
-- return deco.decoration
|
||||||
-- end
|
-- end
|
||||||
-- else
|
-- else
|
||||||
|
@ -209,7 +209,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
--local level = ceil(maxp.y / 3100)
|
--local level = ceil(maxp.y / 3100)
|
||||||
local n = 16
|
local n = 16
|
||||||
local walls = {}
|
local walls = {}
|
||||||
local floor = node['fun_caves:dungeon_floor_1']
|
local inner_floor = node['fun_caves:dungeon_floor_1']
|
||||||
local outer_wall = node['fun_caves:dungeon_wall_2']
|
local outer_wall = node['fun_caves:dungeon_wall_2']
|
||||||
local inner_wall = node['fun_caves:dungeon_wall_1']
|
local inner_wall = node['fun_caves:dungeon_wall_1']
|
||||||
|
|
||||||
|
@ -221,21 +221,21 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
end
|
end
|
||||||
table.shuffle(walls)
|
table.shuffle(walls)
|
||||||
|
|
||||||
local dox, doz = math.random(0, n-1), math.random(0, n-1)
|
local dox, doz = rand(0, n-1), rand(0, n-1)
|
||||||
for z = minp.z, maxp.z do
|
for z = minp.z, maxp.z do
|
||||||
for y = minp.y + y2 * 5, minp.y + y2 * 5 + 4 do
|
for y = minp.y + y2 * 5, minp.y + y2 * 5 + 4 do
|
||||||
local ivm = area:index(minp.x, y, z)
|
local ivm = area:index(minp.x, y, z)
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
if (y - minp.y) % 5 == 0 then
|
if x == minp.x or z == minp.z or x == maxp.x or z == maxp.z then
|
||||||
if math.floor((z - minp.z) / 5) == doz and math.floor((x - minp.x) / 5) == dox and (z - minp.z) % 5 ~= 0 and (x - minp.x) % 5 ~= 0 and y ~= minp.y then
|
data[ivm] = outer_wall
|
||||||
|
elseif (y - minp.y) % 5 == 0 then
|
||||||
|
if floor((z - minp.z) / 5) == doz and floor((x - minp.x) / 5) == dox and (z - minp.z) % 5 ~= 0 and (x - minp.x) % 5 ~= 0 and y ~= minp.y then
|
||||||
data[ivm] = node["air"]
|
data[ivm] = node["air"]
|
||||||
else
|
else
|
||||||
data[ivm] = floor
|
data[ivm] = inner_floor
|
||||||
end
|
end
|
||||||
elseif x == minp.x or z == minp.z or x == maxp.x or z == maxp.z then
|
|
||||||
data[ivm] = outer_wall
|
|
||||||
elseif (z - minp.z) % 5 == 0 or (x - minp.x) % 5 == 0 then
|
elseif (z - minp.z) % 5 == 0 or (x - minp.x) % 5 == 0 then
|
||||||
data[ivm] = inner_wall
|
data[ivm] = DEBUG and node["default:glass"] or inner_wall
|
||||||
else
|
else
|
||||||
data[ivm] = node["air"]
|
data[ivm] = node["air"]
|
||||||
end
|
end
|
||||||
|
@ -248,9 +248,9 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
|
|
||||||
for m = 0, #walls do
|
for m = 0, #walls do
|
||||||
local c = walls[m]
|
local c = walls[m]
|
||||||
local a = math.floor(c / 2)
|
local a = floor(c / 2)
|
||||||
local i = a % n
|
local i = a % n
|
||||||
local j = math.floor(a / n)
|
local j = floor(a / n)
|
||||||
local u = c % 2 == 0 and 1 or 0
|
local u = c % 2 == 0 and 1 or 0
|
||||||
local v = c % 2 == 1 and 1 or 0
|
local v = c % 2 == 1 and 1 or 0
|
||||||
local b = a + u + n * v
|
local b = a + u + n * v
|
||||||
|
@ -259,7 +259,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
local x = (i + u) * 5 + minp.x
|
local x = (i + u) * 5 + minp.x
|
||||||
local y = minp.y + y2 * 5
|
local y = minp.y + y2 * 5
|
||||||
local z = (j + v) * 5 + minp.z
|
local z = (j + v) * 5 + minp.z
|
||||||
--if y > minp.y and math.random(20) == 1 then
|
--if y > minp.y and rand(20) == 1 then
|
||||||
-- for z1 = z + 1, z + 4 do
|
-- for z1 = z + 1, z + 4 do
|
||||||
-- ivm = area:index(x+1, y, z1)
|
-- ivm = area:index(x+1, y, z1)
|
||||||
-- for x1 = x + 1, x + 4 do
|
-- for x1 = x + 1, x + 4 do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue