5 wide paths in progress. Larger spreads up to 8192

This commit is contained in:
paramat 2014-09-09 03:17:33 +01:00
parent fdd5f72e06
commit b1240a7bf4
2 changed files with 268 additions and 25 deletions

View File

@ -1,4 +1,4 @@
pathv6alt 0.2.1 by paramat
pathv6alt 0.2.2 by paramat
For latest stable Minetest back to 0.4.8
Depends default
Licenses: code WTFPL

291
init.lua
View File

@ -1,12 +1,10 @@
-- pathv6alt 0.2.1 by paramat
-- pathv6alt 0.2.2 by paramat
-- For latest stable Minetest and back to 0.4.8
-- Depends default
-- License: code WTFPL
-- walkable dirt path
-- reduce height select persistence, not octaves
-- increase steepness
-- 4 path networks, varying spreads
-- 5 wide roads in progress
-- larger spreads up to 8192
-- Parameters
@ -64,9 +62,9 @@ local np_patha = {
offset = 0,
scale = 1,
spread = {x=1024, y=1024, z=1024},
seed = 11,
seed = 11711,
octaves = 3,
persist = 0.33
persist = 0.4
}
-- 2D noise for pathb
@ -74,10 +72,10 @@ local np_patha = {
local np_pathb = {
offset = 0,
scale = 1,
spread = {x=1024, y=1024, z=1024},
seed = -80033,
octaves = 3,
persist = 0.33
spread = {x=2048, y=2048, z=2048},
seed = -8017,
octaves = 4,
persist = 0.4
}
-- 2D noise for pathc
@ -85,10 +83,10 @@ local np_pathb = {
local np_pathc = {
offset = 0,
scale = 1,
spread = {x=2048, y=2048, z=2048},
seed = -80,
octaves = 4,
persist = 0.33
spread = {x=4096, y=4096, z=4096},
seed = 300707,
octaves = 5,
persist = 0.4
}
-- 2D noise for pathd
@ -96,10 +94,10 @@ local np_pathc = {
local np_pathd = {
offset = 0,
scale = 1,
spread = {x=4096, y=4096, z=4096},
seed = 300707,
octaves = 5,
persist = 0.33
spread = {x=8192, y=8192, z=8192},
seed = -80033,
octaves = 6,
persist = 0.4
}
-- Stuff
@ -212,11 +210,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
if (n_patha >= 0 and n_xprepatha < 0) or (n_patha < 0 and n_xprepatha >= 0) -- patha
or (n_patha >= 0 and n_zprepatha < 0) or (n_patha < 0 and n_zprepatha >= 0)
or (n_pathb >= 0 and n_xprepathb < 0) or (n_pathb < 0 and n_xprepathb >= 0) -- pathb
or (n_pathb >= 0 and n_zprepathb < 0) or (n_pathb < 0 and n_zprepathb >= 0)
or (n_pathc >= 0 and n_xprepathc < 0) or (n_pathc < 0 and n_xprepathc >= 0) -- pathc
or (n_pathc >= 0 and n_zprepathc < 0) or (n_pathc < 0 and n_zprepathc >= 0)
or (n_pathd >= 0 and n_xprepathd < 0) or (n_pathd < 0 and n_xprepathd >= 0) -- pathd
or (n_pathd >= 0 and n_zprepathd < 0) or (n_pathd < 0 and n_zprepathd >= 0) then
or (n_pathb >= 0 and n_zprepathb < 0) or (n_pathb < 0 and n_zprepathb >= 0) then
local wood = true -- scan disk at path level for ground
for k = -1, 1 do
local vi = area:index(x-1, pathy, z+k)
@ -395,6 +389,255 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
if wood and math.random() < 0.25 then
local vi = area:index(x, pathy - 1, z)
for y = pathy - 1, y0, -1 do
local nodid = data[vi]
if nodid == c_stone
or nodid == c_destone then
break
else
data[vi] = c_column
end
vi = vi - emerlen
end
end
elseif (n_pathc >= 0 and n_xprepathc < 0) or (n_pathc < 0 and n_xprepathc >= 0) -- pathc
or (n_pathc >= 0 and n_zprepathc < 0) or (n_pathc < 0 and n_zprepathc >= 0)
or (n_pathd >= 0 and n_xprepathd < 0) or (n_pathd < 0 and n_xprepathd >= 0) -- pathd
or (n_pathd >= 0 and n_zprepathd < 0) or (n_pathd < 0 and n_zprepathd >= 0) then
local wood = true -- scan disk at path level for ground
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_sand
or nodid == c_desand
or nodid == c_dirt
or nodid == c_grass
or nodid == c_stone
or nodid == c_destone then
wood = false
end
vi = vi + 1
end
end
local tunnel = false -- scan disk above path for stone
local excatop
for k = -2, 2 do
local vi = area:index(x-2, pathy+5, z+k)
for i = -2, 2 do
local nodid = data[vi]
if nodid == c_stone
or nodid == c_destone then
tunnel = true
end
vi = vi + 1
end
end
if tunnel then
excatop = pathy + 4 -- tunnel
else
excatop = y1 -- excavate to chunk top
end
if WALK then
if wood then
local vi = area:index(x-2, pathy, z-2)
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairne
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairn
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairn
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairn
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairnw
end
local vi = area:index(x-2, pathy, z-1)
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_staire
end
vi = vi + 1
for iter = 1, 3 do
data[vi] = c_wood
vi = vi + 1
end
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairw
end
local vi = area:index(x-2, pathy, z)
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_staire
end
vi = vi + 1
for iter = 1, 3 do
data[vi] = c_wood
vi = vi + 1
end
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairw
end
local vi = area:index(x-2, pathy, z+1)
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_staire
end
vi = vi + 1
for iter = 1, 3 do
data[vi] = c_wood
vi = vi + 1
end
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairw
end
local vi = area:index(x-2, pathy, z+2)
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairse
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairs
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairs
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairs
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairsw
end
else
local vi = area:index(x-1, pathy, z-1)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairne
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairn
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairnw
end
local vi = area:index(x-1, pathy, z)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstaire
end
vi = vi + 1
data[vi] = c_path
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairw
end
local vi = area:index(x-1, pathy, z+1)
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairse
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairs
end
vi = vi + 1
if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_pstairsw
end
end
for y = pathy + 1, excatop do
for k = -2, 2 do
local vi = area:index(x-2, y, z+k)
for i = -2, 2 do
local nodid = data[vi]
if nodid ~= c_wood
and nodid ~= c_path
and nodid ~= c_stairn
and nodid ~= c_stairs
and nodid ~= c_staire
and nodid ~= c_stairw
and nodid ~= c_stairne
and nodid ~= c_stairnw
and nodid ~= c_stairse
and nodid ~= c_stairsw
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
end
vi = vi + 1
end
end
end
else -- non walkable option
for y = pathy, excatop do
for k = -2, 2 do
local vi = area:index(x-2, y, z+k)
for i = -2, 2 do
if math.abs(k) + math.abs(i) <= 3 then
local nodid = data[vi]
if y == pathy then
if wood then
data[vi] = c_wood
else
data[vi] = c_path
end
elseif nodid ~= c_wood and nodid ~= c_path then
data[vi] = c_air
end
end
vi = vi + 1
end
end
end
end
if wood and math.random() < 0.25 then
local vi = area:index(x, pathy - 1, z)
for y = pathy - 1, y0, -1 do