2 path systems. Dark pathslab side texture. No mount noise: amplify terrain noise

master
Mat 2014-06-27 07:39:05 +01:00
parent 3c3abcf2f0
commit 79649d991d
3 changed files with 80 additions and 32 deletions

View File

@ -1,4 +1,4 @@
path 0.3.1 by paramat
path 0.3.2 by paramat
For latest stable Minetest back to 0.4.8
Depends default
Licenses: code WTFPL

110
init.lua
View File

@ -1,18 +1,22 @@
-- path 0.3.1 by paramat
-- path 0.3.2 by paramat
-- For latest stable Minetest and back to 0.4.8
-- Depends default
-- License: code WTFPL
-- 2 path systems
-- dark pathslab side textures
-- simpler mapgen: amplify terrain noise
-- Parameters
local YCEN = 32 -- Terrain centre
local YWAT = 1 -- Terrain centre
local TERSCA = 16 -- Vertical roads terrain scale
local YCEN = 40 -- Terrain centre
local YWAT = 1 -- Water level
local TERSCA = 24 -- Vertical roads terrain scale
local YBTOP = 5 -- Beach top
local YROCK = 144
local DEPSEL = 8
local YROCK = 256 -- Dirt thins to 1 node at this distance above YWAT
local DEPSEL = 8 -- Depth of dirt at sea level
local APPCHA = 1 / 4 ^ 2 -- Maximum appletree chance per node
local TFLO = 0.03 -- Flora threshold. Keeps flora away from roads.
local TFLO = 0.015 -- Flora threshold. Keeps flora away from roads.
local TPFLO = 0.02 -- Flora path threshold. Keeps flora away from paths.
-- 2D noise for roads terrain
@ -23,18 +27,7 @@ local np_terrain = {
spread = {x=512, y=512, z=512},
seed = -9111,
octaves = 4,
persist = 0.4
}
-- 2D noise for mountains and lakes
local np_mount = {
offset = 0,
scale = 1,
spread = {x=2048, y=2048, z=2048},
seed = 1455511,
octaves = 5,
persist = 0.4
persist = 0.5
}
-- 2D noise for patha
@ -42,7 +35,7 @@ local np_mount = {
local np_patha = {
offset = 0,
scale = 1,
spread = {x=1024, y=1024, z=1024},
spread = {x=2048, y=2048, z=2048},
seed = 11,
octaves = 4,
persist = 0.33
@ -53,7 +46,7 @@ local np_patha = {
local np_pathb = {
offset = 0,
scale = 1,
spread = {x=1024, y=1024, z=1024},
spread = {x=2048, y=2048, z=2048},
seed = -80033,
octaves = 4,
persist = 0.33
@ -70,6 +63,17 @@ local np_pathc = {
persist = 0.33
}
-- 2D noise for pathd
local np_pathd = {
offset = 0,
scale = 1,
spread = {x=512, y=512, z=512},
seed = 300707,
octaves = 4,
persist = 0.33
}
-- 2D noise for trees
local np_tree = {
@ -112,9 +116,9 @@ minetest.register_node("path:path", {
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("path:pathslab", {
minetest.register_node("path:pathslab", { -- pathside texture darker because sunlight propagates = true
description = "Path slab",
tiles = {"path_path.png"},
tiles = {"path_path.png", "path_pathside.png", "path_pathside.png"},
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
@ -285,10 +289,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
local minposxz = {x=x0-1, y=z0-1}
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulensxz):get2dMap_flat(minposxz)
local nvals_mount = minetest.get_perlin_map(np_mount, chulensxz):get2dMap_flat(minposxz)
local nvals_patha = minetest.get_perlin_map(np_patha, chulensxz):get2dMap_flat(minposxz)
local nvals_pathb = minetest.get_perlin_map(np_pathb, chulensxz):get2dMap_flat(minposxz)
local nvals_pathc = minetest.get_perlin_map(np_pathc, chulensxz):get2dMap_flat(minposxz)
local nvals_pathd = minetest.get_perlin_map(np_pathd, chulensxz):get2dMap_flat(minposxz)
local nvals_tree = minetest.get_perlin_map(np_tree, chulensxz):get2dMap_flat(minposxz)
local nixz = 1
@ -300,13 +304,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
local n_xprepatha = false
local n_xprepathb = false
local n_xprepathc = false
local fimadep = math.max(DEPSEL * (1 - (y - YWAT) / YROCK), 0)
local n_xprepathd = false
local fimadep = math.max(DEPSEL * (1 - (y - YWAT) / YROCK), 1)
for x = x0-1, x1 do
local nodid = data[vi]
local nodidu = data[viu]
local n_zprepatha = nvals_patha[(nixz - overlen)]
local n_zprepathb = nvals_pathb[(nixz - overlen)]
local n_zprepathc = nvals_pathc[(nixz - overlen)]
local n_zprepathd = nvals_pathd[(nixz - overlen)]
local chunk = (x >= x0 and z >= z0)
local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1)
@ -319,13 +325,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
local n_pathc = nvals_pathc[nixz]
local n_abspathc = math.abs(n_pathc)
local n_pathd = nvals_pathd[nixz]
local n_abspathd = math.abs(n_pathd)
local n_terrain = nvals_terrain[nixz]
local n_mount = nvals_mount[nixz]
local ysurf = YCEN
+ math.floor((n_terrain + n_abspatha ^ 2 * n_abspathb ^ 2 * n_mount * 32) * TERSCA)
+ math.floor(n_terrain * (1 + n_abspatha ^ 2 * n_abspathb ^ 2 * 32) * TERSCA)
if chunk then
if y == ysurf and y > YBTOP and y < YROCK then
if y == ysurf and y > YBTOP then
if ((n_patha >= 0 and n_xprepatha < 0)
or (n_patha < 0 and n_xprepatha >= 0))
or ((n_patha >= 0 and n_zprepatha < 0)
@ -412,7 +420,45 @@ minetest.register_on_generated(function(minp, maxp, seed)
local via = area:index(x+i, y+1, z+k)
local nodid = data[vi]
local nodida = data[via]
if nodid ~= c_roadblack then
if nodid ~= c_roadblack
and nodid ~= c_roadwhite then
data[vi] = c_path
if nodida == c_grass then
data[via] = c_air
end
end
elseif radsq <= 5 then
local vi = area:index(x+i, y, z+k)
local via = area:index(x+i, y+1, z+k)
local nodid = data[vi]
local nodida = data[via]
if nodid ~= c_roadblack
and nodid ~= c_roadwhite
and nodid ~= c_path
and nodid ~= c_grass
and nodid ~= c_dirt then
data[vi] = c_pathslab
if nodida == c_grass then
data[via] = c_air
end
end
end
end
end
elseif ((n_pathd >= 0 and n_xprepathd < 0)
or (n_pathd < 0 and n_xprepathd >= 0))
or ((n_pathd >= 0 and n_zprepathd < 0)
or (n_pathd < 0 and n_zprepathd >= 0)) then
for i = -2, 2 do
for k = -2, 2 do
local radsq = (math.abs(i)) ^ 2 + (math.abs(k)) ^ 2
if radsq <= 2 then
local vi = area:index(x+i, y, z+k)
local via = area:index(x+i, y+1, z+k)
local nodid = data[vi]
local nodida = data[via]
if nodid ~= c_roadblack
and nodid ~= c_roadwhite then
data[vi] = c_path
if nodida == c_grass then
data[via] = c_air
@ -443,7 +489,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
and nodidu ~= c_roadslab
and nodidu ~= c_pathslab then
data[vi] = c_grass
if n_abspatha > TFLO and n_abspathb > TFLO and n_abspathc > TPFLO
if n_abspatha > TFLO and n_abspathb > TFLO
and n_abspathc > TPFLO and n_abspathd > TPFLO
and math.random() < APPCHA * n_tree and fimadep >= 2 then
path_appletree(x, y+1, z, area, data)
end
@ -461,6 +508,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
n_xprepatha = n_patha
n_xprepathb = n_pathb
n_xprepathc = n_pathc
n_xprepathd = n_pathd
nixz = nixz + 1
nixyz = nixyz + 1
vi = vi + 1

BIN
textures/path_pathside.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B