From 3c3abcf2f0ef902cc4a2cd873ccc9c25e7e4be9f Mon Sep 17 00:00:00 2001 From: Mat Date: Mon, 23 Jun 2014 08:59:44 +0100 Subject: [PATCH] Walkable dirt path with slabs --- README.txt | 2 +- init.lua | 143 +++++++++++++++++++++++++++++++------ textures/path_light.png | Bin 134 -> 0 bytes textures/path_path.png | Bin 0 -> 616 bytes textures/path_redcrete.png | Bin 326 -> 0 bytes 5 files changed, 124 insertions(+), 21 deletions(-) delete mode 100644 textures/path_light.png create mode 100644 textures/path_path.png delete mode 100644 textures/path_redcrete.png diff --git a/README.txt b/README.txt index 741b2bc..f612262 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -path 0.3.0 by paramat +path 0.3.1 by paramat For latest stable Minetest back to 0.4.8 Depends default Licenses: code WTFPL diff --git a/init.lua b/init.lua index 647c522..3dcee43 100644 --- a/init.lua +++ b/init.lua @@ -1,20 +1,21 @@ --- path 0.3.0 by paramat +-- path 0.3.1 by paramat -- For latest stable Minetest and back to 0.4.8 -- Depends default -- License: code WTFPL -- Parameters -local YCEN = 64 -- Terrain centre +local YCEN = 32 -- Terrain centre local YWAT = 1 -- Terrain centre -local TERSCA = 32 -- Vertical base terrain scale +local TERSCA = 16 -- Vertical roads terrain scale local YBTOP = 5 -- Beach top -local YROCK = 128 +local YROCK = 144 local DEPSEL = 8 -local APPCHA = 1 / 79 ^ 2 -- Appletree chance per node +local APPCHA = 1 / 4 ^ 2 -- Maximum appletree chance per node local TFLO = 0.03 -- Flora threshold. Keeps flora away from roads. +local TPFLO = 0.02 -- Flora path threshold. Keeps flora away from paths. --- 2D noise for terrain +-- 2D noise for roads terrain local np_terrain = { offset = 0, @@ -32,7 +33,7 @@ local np_mount = { scale = 1, spread = {x=2048, y=2048, z=2048}, seed = 1455511, - octaves = 7, + octaves = 5, persist = 0.4 } @@ -58,6 +59,28 @@ local np_pathb = { persist = 0.33 } +-- 2D noise for pathc + +local np_pathc = { + offset = 0, + scale = 1, + spread = {x=512, y=512, z=512}, + seed = -80, + octaves = 4, + persist = 0.33 +} + +-- 2D noise for trees + +local np_tree = { + offset = 0, + scale = 1, + spread = {x=256, y=256, z=256}, + seed = 133338, + octaves = 3, + persist = 0.4 +} + -- Nodes minetest.register_node("path:grass", { @@ -80,6 +103,35 @@ minetest.register_node("path:dirt", { sounds = default.node_sound_dirt_defaults(), }) +minetest.register_node("path:path", { + description = "Path", + tiles = {"path_path.png"}, + is_ground_content = false, + groups = {crumbly=2}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_node("path:pathslab", { + description = "Path slab", + tiles = {"path_path.png"}, + drawtype = "nodebox", + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + node_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}}, + }, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}}, + }, + groups = {crumbly=2}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults(), +}) + minetest.register_node("path:stone", { description = "Stone", tiles = {"default_stone.png"}, @@ -90,7 +142,7 @@ minetest.register_node("path:stone", { }) minetest.register_node("path:appleleaf", { - description = "Appletree Leaves", + description = "Appletree leaves", drawtype = "allfaces_optional", visual_scale = 1.3, tiles = {"default_leaves.png"}, @@ -101,20 +153,19 @@ minetest.register_node("path:appleleaf", { }) minetest.register_node("path:roadblack", { - description = "Road Black", + description = "Road black", tiles = {"path_roadblack.png"}, groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), }) minetest.register_node("path:roadslab", { - description = "Road Slab", + description = "Road slab", tiles = {"path_roadblack.png"}, drawtype = "nodebox", paramtype = "light", is_ground_content = false, sunlight_propagates = true, - buildable_to = false, node_box = { type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}}, @@ -128,7 +179,7 @@ minetest.register_node("path:roadslab", { }) minetest.register_node("path:roadwhite", { - description = "Road White", + description = "Road white", tiles = {"path_roadwhite.png"}, groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), @@ -141,7 +192,7 @@ path = {} -- Set mapgen parameters minetest.register_on_mapgen_init(function(mgparams) - minetest.set_mapgen_params({mgname="singlenode", water_level=-32}) + minetest.set_mapgen_params({mgname="singlenode"}) end) -- Spawn player @@ -217,6 +268,8 @@ minetest.register_on_generated(function(minp, maxp, seed) local c_water = minetest.get_content_id("default:water_source") local c_sand = minetest.get_content_id("default:sand") + local c_path = minetest.get_content_id("path:path") + local c_pathslab = minetest.get_content_id("path:pathslab") local c_grass = minetest.get_content_id("path:grass") local c_dirt = minetest.get_content_id("path:dirt") local c_stone = minetest.get_content_id("path:stone") @@ -235,6 +288,8 @@ minetest.register_on_generated(function(minp, maxp, seed) 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_tree = minetest.get_perlin_map(np_tree, chulensxz):get2dMap_flat(minposxz) local nixz = 1 local nixyz = 1 @@ -244,13 +299,16 @@ minetest.register_on_generated(function(minp, maxp, seed) local viu = area:index(x0-1, y-1, z) local n_xprepatha = false local n_xprepathb = false + local n_xprepathc = false local fimadep = math.max(DEPSEL * (1 - (y - YWAT) / YROCK), 0) 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 chunk = (x >= x0 and z >= z0) + local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1) local n_patha = nvals_patha[nixz] local n_abspatha = math.abs(n_patha) @@ -258,9 +316,13 @@ minetest.register_on_generated(function(minp, maxp, seed) local n_pathb = nvals_pathb[nixz] local n_abspathb = math.abs(n_pathb) + local n_pathc = nvals_pathc[nixz] + local n_abspathc = math.abs(n_pathc) + 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) + local ysurf = YCEN + + math.floor((n_terrain + n_abspatha ^ 2 * n_abspathb ^ 2 * n_mount * 32) * TERSCA) if chunk then if y == ysurf and y > YBTOP and y < YROCK then @@ -291,7 +353,8 @@ minetest.register_on_generated(function(minp, maxp, seed) if nodid ~= c_roadblack and nodid ~= c_roadwhite and nodid ~= c_grass - and nodid ~= c_dirt then + and nodid ~= c_dirt + and nodid ~= c_path then data[vi] = c_roadslab if nodida == c_grass then data[via] = c_air @@ -327,7 +390,8 @@ minetest.register_on_generated(function(minp, maxp, seed) if nodid ~= c_roadblack and nodid ~= c_roadwhite and nodid ~= c_grass - and nodid ~= c_dirt then + and nodid ~= c_dirt + and nodid ~= c_path then data[vi] = c_roadslab if nodida == c_grass then data[via] = c_air @@ -336,13 +400,51 @@ minetest.register_on_generated(function(minp, maxp, seed) end end end + elseif ((n_pathc >= 0 and n_xprepathc < 0) + or (n_pathc < 0 and n_xprepathc >= 0)) + or ((n_pathc >= 0 and n_zprepathc < 0) + or (n_pathc < 0 and n_zprepathc >= 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 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 nodid ~= c_roadblack and nodid ~= c_roadwhite + and nodid ~= c_path and nodidu ~= c_roadblack - and nodidu ~= c_roadslab then + and nodidu ~= c_roadslab + and nodidu ~= c_pathslab then data[vi] = c_grass - if n_abspatha > TFLO and n_abspathb > TFLO - and math.random() < APPCHA then + if n_abspatha > TFLO and n_abspathb > TFLO and n_abspathc > TPFLO + and math.random() < APPCHA * n_tree and fimadep >= 2 then path_appletree(x, y+1, z, area, data) end end @@ -350,7 +452,7 @@ minetest.register_on_generated(function(minp, maxp, seed) data[vi] = c_stone elseif y <= YBTOP and y <= ysurf then data[vi] = c_sand - elseif y < ysurf and nodid ~= c_roadblack then + elseif y < ysurf and nodid ~= c_roadblack and nodid ~= c_path then data[vi] = c_dirt elseif y <= YWAT and y > ysurf then -- water data[vi] = c_water @@ -358,6 +460,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end n_xprepatha = n_patha n_xprepathb = n_pathb + n_xprepathc = n_pathc nixz = nixz + 1 nixyz = nixyz + 1 vi = vi + 1 diff --git a/textures/path_light.png b/textures/path_light.png deleted file mode 100644 index 523f6bf84bb570b90dbc06de73cf7e31f41826bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z8pdfpRr>`sfJyt0eBV#w-qVqr@2~QWt5RLQ6fBv^LsvJ0Sz+hEk$l-#k a3=BVxFfsFl=N|&9VeoYIb6Mw<&;$T76CvOL diff --git a/textures/path_path.png b/textures/path_path.png new file mode 100644 index 0000000000000000000000000000000000000000..b57196e6a61b976a3fc3058b73f87bd4c93fb9a4 GIT binary patch literal 616 zcmV-u0+;=XP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RZ1r-JcIYt$%9smFV`bk7VR4C6i z!C6AvKoAAM*UO9~Ti9R-TsfD>4RW*)7TePFEZzA^75)D8Q&euZjhUw@MTEOY#9kT` z&$DXMW-aA}@O^J8DppKYg~_amNS+cir*Gp9%VA0>MMSHOg%_1ls)C?d0i>LI>tl@T_x<6tq&$I8_F{WGJ+40d^Yc1SS##Ei z0Kwf^xLQ4~3lVL%&D{YU*7<(Dj}ck5l*-KP!+kh2M?^$y_wx78CkSH<1Zt_8G-vJZ zr^i)GsW~e#MMQ7?e%p!Y@#)lCPdRB)A|g<=`fxg0F-=J#f|=cY-z`Ar^BM@vO8)_f z2rE`=R{#Kfc(q#g`tsuu1SSR`B1{+&z4m>x03DB$iV6TL_VICjem)ZgvxJAJAiO(l zx3AADtDe_|gmttL5%W zW=zb&qS9NBh_|;V77mYU^?uv+ayb#xzL}LKO6z)Hf@Y0~h!h?GdhJ%4)wXR#MF;>? z)&~LL0agaFFna5~_1@jAnKfp9dwo&>V5TuzcOTw|AC}Cbt+rRX=ZGLC z1%TlIzQ491WtqW)c?w0000`sfJyvN^9l=K>i>?8MZg{#lhG?A64LUgShyjQ5q10U7+ZW6B z9k6|(vF}c$kz^8!5Z8}A@q!awTtfPp=Du1fmtMMAM)TuZwuF}EnT!rB=cfs7oRn7F zc)?g$ux5hPsx5pCuU>L8y!N^i`_-;>uI$P?D^D5luI=NiSafyS^OfqIDkjH@O3#-m z?|gn)Rq$%L;nj#~oDaX1y)h{lkKifn|FU))Zxw@1Y;1|}f7xWSX4#0H_O41!Khs2C zU)iwm^XubZU4+ykwO7vld^NsxlOIpbiZycoEf}snV|~2yQe0Q@DV2^Dax=d%@6|q~ VuyX0{IG`UHJYD@<);T3K0RSeces}-?