Reduce steepness to 0.8. Finish wide walkable dirt paths. Quad column pattern for wide paths. Scan for air to avoid dirt bridges

This commit is contained in:
paramat 2014-09-10 04:56:57 +01:00
parent b1240a7bf4
commit c8cb1aa9bc
2 changed files with 95 additions and 130 deletions

View File

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

147
init.lua
View File

@ -1,15 +1,17 @@
-- pathv6alt 0.2.2 by paramat -- pathv6alt 0.2.3 by paramat
-- For latest stable Minetest and back to 0.4.8 -- For latest stable Minetest and back to 0.4.8
-- Depends default -- Depends default
-- License: code WTFPL -- License: code WTFPL
-- 5 wide roads in progress -- reduce steepness to 0.8
-- larger spreads up to 8192 -- finish wide walkable dirt paths
-- quad column pattern for wide paths
-- scan for air to avoid dirt bridges
-- Parameters -- Parameters
local WALK = true -- walkable paths local WALK = true -- walkable paths
local HSAMP = 0.9 -- Height select amplitude. Maximum steepness of paths local HSAMP = 0.8 -- Height select amplitude. Maximum steepness of paths
local HSOFF = -0.2 -- Height select noise offset. Bias paths towards base (-) or higher (+) terrain local HSOFF = -0.2 -- Height select noise offset. Bias paths towards base (-) or higher (+) terrain
-- 2D noise for base terrain -- 2D noise for base terrain
@ -126,6 +128,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local data = vm:get_data() local data = vm:get_data()
local c_air = minetest.get_content_id("air") local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("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")
@ -211,18 +214,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
or (n_patha >= 0 and n_zprepatha < 0) or (n_patha < 0 and n_zprepatha >= 0) 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_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) 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 local wood = false -- scan disk at path level for air
for k = -1, 1 do for k = -1, 1 do
local vi = area:index(x-1, pathy, z+k) local vi = area:index(x-1, pathy, z+k)
for i = -1, 1 do for i = -1, 1 do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_sand if nodid == c_air
or nodid == c_desand or nodid == c_ignore then
or nodid == c_dirt wood = true
or nodid == c_grass
or nodid == c_stone
or nodid == c_destone then
wood = false
end end
vi = vi + 1 vi = vi + 1
end end
@ -406,18 +405,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
or (n_pathc >= 0 and n_zprepathc < 0) or (n_pathc < 0 and n_zprepathc >= 0) 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_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_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 local wood = false -- scan disk at path level for air
for k = -2, 2 do for k = -2, 2 do
local vi = area:index(x-2, pathy, z+k) local vi = area:index(x-2, pathy, z+k)
for i = -2, 2 do for i = -2, 2 do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_sand if nodid == c_air
or nodid == c_desand or nodid == c_ignore then
or nodid == c_dirt wood = true
or nodid == c_grass
or nodid == c_stone
or nodid == c_destone then
wood = false
end end
vi = vi + 1 vi = vi + 1
end end
@ -436,6 +431,7 @@ 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 + 4 -- tunnel excatop = pathy + 4 -- tunnel
else else
@ -445,147 +441,112 @@ minetest.register_on_generated(function(minp, maxp, seed)
if WALK then if WALK then
if wood then 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_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairne data[vi] = c_stairne
end end
for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairn data[vi] = c_stairn
end end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairn
end end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairn
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairnw data[vi] = c_stairnw
end end
local vi = area:index(x-2, pathy, z-1) for k = -1, 1 do
if data[vi] ~= c_wood local vi = area:index(x-2, pathy, z+k)
and data[vi] ~= c_path then if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_staire data[vi] = c_staire
end end
vi = vi + 1
for iter = 1, 3 do for iter = 1, 3 do
data[vi] = c_wood
vi = vi + 1 vi = vi + 1
data[vi] = c_wood
end end
if data[vi] ~= c_wood vi = vi + 1
and data[vi] ~= c_path then if data[vi] ~= c_path
and data[vi] ~= c_wood then
data[vi] = c_stairw data[vi] = c_stairw
end 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 end
local vi = area:index(x-2, pathy, z+2) local vi = area:index(x-2, pathy, z+2)
if data[vi] ~= c_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairse data[vi] = c_stairse
end end
for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairs data[vi] = c_stairs
end end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairs
end end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_wood if data[vi] ~= c_path
and data[vi] ~= c_path then and data[vi] ~= c_wood then
data[vi] = c_stairs
end
vi = vi + 1
if data[vi] ~= c_wood
and data[vi] ~= c_path then
data[vi] = c_stairsw data[vi] = c_stairsw
end end
else else
local vi = area:index(x-1, pathy, z-1) local vi = area:index(x-2, pathy, z-2)
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairne data[vi] = c_pstairne
end end
for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairn data[vi] = c_pstairn
end end
end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairnw data[vi] = c_pstairnw
end end
local vi = area:index(x-1, pathy, z) for k = -1, 1 do
local vi = area:index(x-2, pathy, z+k)
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstaire data[vi] = c_pstaire
end end
for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
data[vi] = c_path data[vi] = c_path
end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairw data[vi] = c_pstairw
end end
end
local vi = area:index(x-1, pathy, z+1) local vi = area:index(x-2, pathy, z+2)
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairse data[vi] = c_pstairse
end end
for iter = 1, 3 do
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairs data[vi] = c_pstairs
end end
end
vi = vi + 1 vi = vi + 1
if data[vi] ~= c_path if data[vi] ~= c_path
and data[vi] ~= c_wood then and data[vi] ~= c_wood then
data[vi] = c_pstairsw data[vi] = c_pstairsw
end end
end end
for y = pathy + 1, excatop do for y = pathy + 1, excatop do
for k = -2, 2 do for k = -2, 2 do
local vi = area:index(x-2, y, z+k) local vi = area:index(x-2, y, z+k)
@ -638,8 +599,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
if wood and math.random() < 0.25 then if wood and math.random() < 0.2 then
local vi = area:index(x, pathy - 1, z) for i = -1, 1, 2 do
for k = -1, 1, 2 do
local vi = area:index(x+i, pathy-1, z+k)
for y = pathy - 1, y0, -1 do for y = pathy - 1, y0, -1 do
local nodid = data[vi] local nodid = data[vi]
if nodid == c_stone if nodid == c_stone
@ -653,6 +616,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
end
end
n_xprepatha = n_patha n_xprepatha = n_patha
n_xprepathb = n_pathb n_xprepathb = n_pathb