Simplify and stuff

This commit is contained in:
paramat 2016-07-31 06:38:46 +01:00
parent 183a9380c3
commit 3b8356eada
4 changed files with 131 additions and 372 deletions

@ -1,4 +1,4 @@
pathv7 0.1.1 by paramat pathv7 0.1.2 by paramat
For Minetest 0.4.14 and later For Minetest 0.4.14 and later
Depends default stairs Depends default stairs
Licenses: Code LGPLv2.1, textures CC BY-SA 3.0 Licenses: Code LGPLv2.1, textures CC BY-SA 3.0

243
init.lua

@ -1,14 +1,9 @@
-- Parameters -- Parameters
local YMAXMINP = -32 -- Maximum minp.y of generated chunks local YMAXMINP = -32 -- Maximum minp.y of generated chunks
-- (-32 for default mapgen v6. 48, 128, 208 for higher)
local HSAMP = 0.03 -- Height select amplitude. Maximum steepness of paths local HSAMP = 0.03 -- Height select amplitude. Maximum steepness of paths
local HSOFF = 0.0 -- Height select offset.
-- Bias paths towards lower (-) or higher (+) terrain
local TCOL = 0.3 -- Column noise threshold. Bridge column density
-- Mapgen v7 noises
-- Mapgen v7 parameters
-- 2D noise for base terrain -- 2D noise for base terrain
@ -39,11 +34,11 @@ local np_select = {
scale = 16, scale = 16,
spread = {x = 500, y = 500, z = 500}, spread = {x = 500, y = 500, z = 500},
seed = 4213, seed = 4213,
octaves = 5, -- default 6 octaves = 4, -- default 6
persist = 0.3 -- default 0.7 persist = 0.3 -- default 0.7
} }
-- Mod path parameters -- Mod noises
-- 2D noise for patha -- 2D noise for patha
@ -144,8 +139,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
local y0 = minp.y local y0 = minp.y
local z0 = minp.z local z0 = minp.z
local c_air = minetest.get_content_id("air") local c_air = minetest.CONTENT_AIR
local c_ignore = minetest.get_content_id("ignore") local c_ignore = minetest.CONTENT_IGNORE
local c_tree = minetest.get_content_id("default:tree") local c_tree = minetest.get_content_id("default:tree")
local c_sand = minetest.get_content_id("default:sand") local c_sand = minetest.get_content_id("default:sand")
local c_dirt = minetest.get_content_id("default:dirt") local c_dirt = minetest.get_content_id("default:dirt")
@ -158,9 +153,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_destone = minetest.get_content_id("default:desert_stone") local c_destone = minetest.get_content_id("default:desert_stone")
local c_ice = minetest.get_content_id("default:ice") local c_ice = minetest.get_content_id("default:ice")
local c_meselamp = minetest.get_content_id("default:meselamp") local c_meselamp = minetest.get_content_id("default:meselamp")
local c_gravel = minetest.get_content_id("default:gravel")
local c_tree = minetest.get_content_id("default:tree")
local c_jungletree = minetest.get_content_id("default:jungletree")
local c_pinetree = minetest.get_content_id("default:pine_tree")
local c_acaciatree = minetest.get_content_id("default:acacia_tree")
local c_aspentree = minetest.get_content_id("default:aspen_tree")
local c_wood = minetest.get_content_id("pathv7:junglewood") local c_wood = minetest.get_content_id("pathv7:junglewood")
local c_path = minetest.get_content_id("pathv7:path")
local c_column = minetest.get_content_id("pathv7:bridgewood") local c_column = minetest.get_content_id("pathv7:bridgewood")
local c_stairn = minetest.get_content_id("pathv7:stairn") local c_stairn = minetest.get_content_id("pathv7:stairn")
@ -172,18 +172,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_stairse = minetest.get_content_id("pathv7:stairse") local c_stairse = minetest.get_content_id("pathv7:stairse")
local c_stairsw = minetest.get_content_id("pathv7:stairsw") local c_stairsw = minetest.get_content_id("pathv7:stairsw")
local c_pstairn = minetest.get_content_id("pathv7:pstairn")
local c_pstairs = minetest.get_content_id("pathv7:pstairs")
local c_pstaire = minetest.get_content_id("pathv7:pstaire")
local c_pstairw = minetest.get_content_id("pathv7:pstairw")
local c_pstairne = minetest.get_content_id("pathv7:pstairne")
local c_pstairnw = minetest.get_content_id("pathv7:pstairnw")
local c_pstairse = minetest.get_content_id("pathv7:pstairse")
local c_pstairsw = minetest.get_content_id("pathv7:pstairsw")
local sidelen = x1 - x0 + 1 local sidelen = x1 - x0 + 1
local emerlen = sidelen + 32 local emerlen = sidelen + 32
local overlen = sidelen + 5 -- noisemap x, z from minp-3 to maxp+2 local overlen = sidelen + 5
local chulens = {x = overlen, y = overlen, z = 1} local chulens = {x = overlen, y = overlen, z = 1}
local minpos = {x = x0 - 3, y = z0 - 3} local minpos = {x = x0 - 3, y = z0 - 3}
@ -240,7 +231,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
if base < alt then if base < alt then
base = alt base = alt
end end
local tblend = 0.5 + HSAMP * (select - 0.5) + HSOFF local tblend = 0.5 + HSAMP * (select - 0.5)
tblend = math.min(math.max(tblend, 0), 1) tblend = math.min(math.max(tblend, 0), 1)
local tlevel = base * tblend + alt * (1 - tblend) local tlevel = base * tblend + alt * (1 - tblend)
-- TODO allow path above -- TODO allow path above
@ -267,10 +258,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
or (n_pathd < 0 and n_zprepathd >= 0) then or (n_pathd < 0 and n_zprepathd >= 0) then
if pathy > y1 then if pathy > y1 then
-- build columns through this chunk -- build columns through this chunk
if abscol < TCOL then if abscol < 0.3 then
for i = -1, 1, 2 do for xx = x - 1, x + 1, 2 do
for k = -1, 1, 2 do for zz = z - 1, z + 1, 2 do
local vi = area:index(x + i, y1, z + k) local vi = area:index(xx, y1, zz)
for y = 1, sidelen do for y = 1, sidelen do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_stone if nodid == c_stone
@ -288,27 +279,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
elseif pathy >= y0 then elseif pathy >= y0 then
-- path in chunk -- path in chunk
-- scan disk at path level for dirt -- scan disk 5 nodes above path
local wood = true
for k = -2, 2 do
local vi = area:index(x - 2, pathy, z + k)
for i = -2, 2 do
local nodid = data[vi]
if nodid == c_dirt
or nodid == c_grass
or nodid == c_dirtsnow
or nodid == c_drygrass then
wood = false -- use dirt path node
end
vi = vi + 1
end
end
-- scan disk 5 nodes above path for stone/ice
local tunnel = false local tunnel = false
local excatop local excatop
for k = -2, 2 do for zz = z - 2, z + 2 do
local vi = area:index(x - 2, pathy + 5, z + k) local vi = area:index(x - 2, pathy + 5, zz)
for i = -2, 2 do for xx = x - 2, x + 2 do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_stone if nodid == c_stone
or nodid == c_destone or nodid == c_destone
@ -319,36 +295,30 @@ minetest.register_on_generated(function(minp, maxp, seed)
vi = vi + 1 vi = vi + 1
end end
end end
if tunnel then if tunnel then
excatop = pathy + 5 -- tunnel excatop = pathy + 5 -- tunnel
else else
excatop = y1 -- excavate to chunk top excatop = y1 -- excavate to chunk top
end end
-- place path node brush -- place path node brush
if wood then
local vi = area:index(x - 2, pathy, z - 2) local vi = area:index(x - 2, pathy, z - 2)
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairne data[vi] = c_stairne
end end
for iter = 1, 3 do for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairn data[vi] = c_stairn
end end
end end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairnw data[vi] = c_stairnw
end end
for zz = z - 1, z + 1 do
for k = -1, 1 do local vi = area:index(x - 2, pathy, zz)
local vi = area:index(x - 2, pathy, z + k) if data[vi] ~= c_wood then
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_staire data[vi] = c_staire
end end
for iter = 1, 3 do for iter = 1, 3 do
@ -356,108 +326,59 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[vi] = c_wood data[vi] = c_wood
end end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairw data[vi] = c_stairw
end end
end end
local vi = area:index(x - 2, pathy, z + 2) local vi = area:index(x - 2, pathy, z + 2)
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairse data[vi] = c_stairse
end end
for iter = 1, 3 do for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairs data[vi] = c_stairs
end end
end end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_wood then
and data[vi] ~= c_wood then
data[vi] = c_stairsw data[vi] = c_stairsw
end end
else
local vi = area:index(x - 2, pathy, z - 2)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairne
end
for iter = 1, 3 do
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairn
end
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairnw
end
for k = -1, 1 do
local vi = area:index(x - 2, pathy, z + k)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstaire
end
for iter = 1, 3 do
vi = vi + 1
data[vi] = c_path
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairw
end
end
local vi = area:index(x - 2, pathy, z + 2)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairse
end
for iter = 1, 3 do
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairs
end
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairsw
end
end
-- excavate above path -- excavate above path
local det_destone = false
local det_sastone = false
local det_ice = false
for y = pathy + 1, excatop do for y = pathy + 1, excatop do
for k = -2, 2 do for zz = z - 2, z + 2 do
local vi = area:index(x - 2, y, z + k) local vi = area:index(x - 2, y, zz)
for i = -2, 2 do for xx = x - 2, x + 2 do
local nodid = data[vi] local nodid = data[vi]
if y == excatop then if nodid == c_destone then
if nodid == c_dirt det_destone = true
or nodid == c_grass elseif nodid == c_sastone then
or nodid == c_drygrass det_sastone = true
or nodid == c_dirtsnow then elseif nodid == c_ice then
data[vi] = c_stone det_ice = true
elseif nodid == c_desand then
data[vi] = c_destone
elseif tunnel
and math.random() < 0.05
and (nodid == c_stone
or nodid == c_destone
or nodid == c_sastone
or nodid == c_ice) then
data[vi] = c_meselamp
end end
elseif y <= pathy + 4 then if tunnel and y == excatop then -- tunnel ceiling
if nodid ~= c_air
and nodid ~= c_ignore
and nodid ~= c_meselamp then
if math.random() < 0.1 then
data[vi] = c_meselamp
elseif det_destone then
data[vi] = c_destone
elseif det_sastone then
data[vi] = c_sastone
elseif det_ice then
data[vi] = c_ice
else
data[vi] = c_stone
end
end
elseif y <= pathy + 5 then
if nodid ~= c_wood if nodid ~= c_wood
and nodid ~= c_path
and nodid ~= c_stairn and nodid ~= c_stairn
and nodid ~= c_stairs and nodid ~= c_stairs
and nodid ~= c_staire and nodid ~= c_staire
@ -465,15 +386,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
and nodid ~= c_stairne and nodid ~= c_stairne
and nodid ~= c_stairnw and nodid ~= c_stairnw
and nodid ~= c_stairse and nodid ~= c_stairse
and nodid ~= c_stairsw and nodid ~= c_stairsw then
and nodid ~= c_pstairn
and nodid ~= c_pstairs
and nodid ~= c_pstaire
and nodid ~= c_pstairw
and nodid ~= c_pstairne
and nodid ~= c_pstairnw
and nodid ~= c_pstairse
and nodid ~= c_pstairsw then
data[vi] = c_air data[vi] = c_air
end end
else else
@ -483,25 +396,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
-- bridge structure
if wood then -- bridge understructure
for i = -1, 1 do for zz = z - 1, z + 1 do
for k = -1, 1 do local vi = area:index(x - 1, pathy - 1, zz)
if not (i == 0 and k == 0) then for xx = x - 1, x + 1 do
local vi = area:index(x + i, pathy - 1, z + k)
for y = 1, 2 do
data[vi] = c_column data[vi] = c_column
vi = vi - emerlen vi = vi + 1
end end
end end
end local vi = area:index(x, pathy - 2, z)
end data[vi] = c_column
-- columns
if abscol < TCOL then -- bridge columns
for i = -1, 1, 2 do if abscol < 0.3 then
for k = -1, 1, 2 do for xx = x - 1, x + 1, 2 do
local vi = area:index(x + i, pathy - 3, z + k) for zz = z - 1, z + 1, 2 do
for y = pathy - 3, y0, -1 do local vi = area:index(xx, pathy - 2, zz)
for y = pathy - 2, y0, -1 do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_stone if nodid == c_stone
or nodid == c_destone or nodid == c_destone
@ -519,7 +431,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
end
n_xprepatha = n_patha n_xprepatha = n_patha
n_xprepathb = n_pathb n_xprepathb = n_pathb

152
nodes.lua

@ -6,14 +6,6 @@ minetest.register_node("pathv7:junglewood", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
minetest.register_node("pathv7:path", {
description = "Dirt path",
tiles = {"pathv7_path.png"},
is_ground_content = false,
groups = {crumbly = 2},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:bridgewood", { minetest.register_node("pathv7:bridgewood", {
description = "Bridge wood", description = "Bridge wood",
tiles = {"pathv7_bridgewood.png"}, tiles = {"pathv7_bridgewood.png"},
@ -157,147 +149,3 @@ minetest.register_node("pathv7:stairsw", {
}, },
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
minetest.register_node("pathv7:pstairn", {
description = "Dirt stair N",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairs", {
description = "Dirt stair S",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, -0.5, 0.5, 0.5, 0},
},
},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("pathv7:pstaire", {
description = "Dirt stair E",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{0, 0, -0.5, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairw", {
description = "Dirt stair W",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, -0.5, 0, 0.5, 0.5},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairne", {
description = "Dirt stair NE",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{0, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairnw", {
description = "Dirt stair NW",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairse", {
description = "Dirt stair SE",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{0, 0, -0.5, 0.5, 0.5, 0},
},
},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("pathv7:pstairsw", {
description = "Dirt stair SW",
tiles = {"pathv7_path.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {crumbly = 2},
drop = "default:dirt",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, -0.5, 0, 0.5, 0},
},
},
sounds = default.node_sound_dirt_defaults(),
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B