From e7295638ed557de5c8b2f93e5006cf86f0338019 Mon Sep 17 00:00:00 2001 From: paramat Date: Tue, 1 Apr 2014 01:39:57 +0100 Subject: [PATCH] Singlenode realm, water y = 1, auto spawn on low land, acacialeaf --- README.txt | 2 +- functions.lua | 148 ++++++++++++++++++++++++++++- init.lua | 23 ++--- nodes.lua | 11 +++ textures/watershed_bucketwater.png | Bin 0 -> 330 bytes 5 files changed, 166 insertions(+), 18 deletions(-) create mode 100644 textures/watershed_bucketwater.png diff --git a/README.txt b/README.txt index fe1c880..e2cc86c 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -watershed 0.2.15 by paramat +watershed 0.2.16 by paramat For latest stable Minetest back to 0.4.8 Depends default Licenses: code WTFPL \ No newline at end of file diff --git a/functions.lua b/functions.lua index ea66186..4ac0183 100644 --- a/functions.lua +++ b/functions.lua @@ -123,7 +123,7 @@ end function watershed_acaciatree(x, y, z, area, data) local c_tree = minetest.get_content_id("default:tree") - local c_leaves = minetest.get_content_id("default:leaves") + local c_wsaccleaf = minetest.get_content_id("watershed:acacialeaf") for j = -3, 6 do if j == 6 then for i = -4, 4 do @@ -131,7 +131,7 @@ function watershed_acaciatree(x, y, z, area, data) if not (i == 0 or k == 0) then if math.random(5) ~= 2 then local vil = area:index(x + i, y + j, z + k) - data[vil] = c_leaves + data[vil] = c_wsaccleaf end end end @@ -208,7 +208,7 @@ bucket.register_liquid( "watershed:water", "watershed:waterflow", "watershed:bucket_water", - "bucket_water.png", + "watershed_bucketwater.png", "WS Water Bucket" ) @@ -249,4 +249,144 @@ minetest.register_abm({ minetest.set_node(pos, {name="default:obsidian"}) minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25}) end, -}) \ No newline at end of file +}) + +-- Set mapgen parameters + +minetest.register_on_mapgen_init(function(mgparams) + minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"}) +end) + +-- Spawn player + +function spawnplayer(player) + local TERCEN = -160 -- Terrain 'centre', average seabed level + local TERSCA = 512 -- Vertical terrain scale + local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges + local XLSAMP = 0.2 -- Extra large scale height variation amplitude + local BASAMP = 0.4 -- Base terrain amplitude + local CANAMP = 0.4 -- Canyon terrain amplitude + local CANEXP = 1.33 -- Canyon shape exponent + local xsp + local ysp + local zsp + local np_rough = { + offset = 0, + scale = 1, + spread = {x=512, y=512, z=512}, + seed = 593, + octaves = 6, + persist = 0.63 + } + local np_smooth = { + offset = 0, + scale = 1, + spread = {x=512, y=512, z=512}, + seed = 593, + octaves = 6, + persist = 0.3 + } + local np_fault = { + offset = 0, + scale = 1, + spread = {x=512, y=1024, z=512}, + seed = 14440002, + octaves = 6, + persist = 0.5 + } + local np_base = { + offset = 0, + scale = 1, + spread = {x=4096, y=4096, z=4096}, + seed = 8890, + octaves = 4, + persist = 0.4 + } + local np_xlscale = { + offset = 0, + scale = 1, + spread = {x=8192, y=8192, z=8192}, + seed = -72, + octaves = 3, + persist = 0.4 + } + for chunk = 1, 64 do + local xr = math.random(-2000, 2000) + local zr = math.random(-2000, 2000) + print ("[watershed] xr "..xr) + print ("[watershed] zr "..zr) + local x0 = math.floor((80 * math.floor((xr + 32) / 80)) - 32) + local z0 = math.floor((80 * math.floor((zr + 32) / 80)) - 32) + local y0 = -32 + local x1 = x0 + 79 + local z1 = z0 + 79 + local y1 = 47 + + local sidelen = 80 + local chulens = {x=sidelen, y=sidelen, z=sidelen} + local minposxyz = {x=x0, y=y0, z=z0} + local minposxz = {x=x0, y=z0} + + local nvals_rough = minetest.get_perlin_map(np_rough, chulens):get3dMap_flat(minposxyz) + local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minposxyz) + local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz) + + local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz) + local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz) + + local nixz = 1 + local nixyz = 1 + for z = z0, z1 do + for y = y0, y1 do + for x = x0, x1 do + local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP + local n_base = nvals_base[nixz] + local terblen = math.max(1 - math.abs(n_base), 0) + local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad + local density + if nvals_fault[nixyz] >= 0 then + density = densitybase + + math.abs(nvals_rough[nixyz] * terblen + + nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP + else + density = densitybase + + math.abs(nvals_rough[nixyz] * terblen + - nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP + end + if y >= 1 and density > -0.01 and density < 0 then + ysp = y + 2 + xsp = x + zsp = z + break + end + nixz = nixz + 1 + nixyz = nixyz + 1 + end + if ysp then + break + end + nixz = nixz - 80 + end + if ysp then + break + end + nixz = nixz + 80 + end + if ysp then + break + end + end + print ("[watershed] xsp "..xsp) + print ("[watershed] ysp "..ysp) + print ("[watershed] zsp "..zsp) + player:setpos({x=xsp, y=ysp, z=zsp}) +end + +minetest.register_on_newplayer(function(player) + spawnplayer(player) +end) + +minetest.register_on_respawnplayer(function(player) + spawnplayer(player) + return true +end) \ No newline at end of file diff --git a/init.lua b/init.lua index 49b6700..c24db6d 100644 --- a/init.lua +++ b/init.lua @@ -1,24 +1,21 @@ --- watershed 0.2.15 by paramat +-- watershed 0.2.16 by paramat -- For latest stable Minetest and back to 0.4.8 -- Depends default -- License: code WTFPL --- greener freshwater in rivers --- magma rising at ridges --- lavacooling --- turquiose freshwater in rivers +-- acacialeaf -- TODO -- all tree heights vary -- fog --- singlenode game version +-- singlenode and then game version -- Parameters -local YMIN = 5000 -- Approximate base of realm stone -local YMAX = 9000 -- Approximate top of atmosphere / mountains / floatlands -local TERCEN = 6856 -- Terrain 'centre', average seabed level -local YWAT = 7016 -- Sea level -local YCLOUD = 7144 -- Cloud level +local YMIN = -33000 -- Approximate base of realm stone +local YMAX = 33000 -- Approximate top of atmosphere / mountains / floatlands +local TERCEN = -160 -- Terrain 'centre', average seabed level +local YWAT = 1 -- Sea surface y +local YCLOUD = 128 -- Cloud level local TERSCA = 512 -- Vertical terrain scale local XLSAMP = 0.2 -- Extra large scale height variation amplitude @@ -30,7 +27,7 @@ local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floa local TSTONE = 0.01 -- Density threshold for stone, depth of soil at TERCEN local TRIV = -0.015 -- Maximum densitybase threshold for river water local TSAND = -0.018 -- Maximum densitybase threshold for river sand -local TLAVA = 1 +local TLAVA = 2 -- Maximum densitybase threshold for lava local FIST = 0 -- Fissure threshold at surface, controls size of fissure entrances at surface local FISEXP = 0.02 -- Fissure expansion rate under surface local ORETHI = 0.001 -- Ore seam thickness tuner @@ -624,7 +621,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end vm:set_data(data) - vm:set_lighting({day=0, night=0}) + -- vm:set_lighting({day=0, night=0}) vm:calc_lighting() vm:write_to_map(data) local chugent = math.ceil((os.clock() - t1) * 1000) diff --git a/nodes.lua b/nodes.lua index 9cb66a3..73642e0 100644 --- a/nodes.lua +++ b/nodes.lua @@ -9,6 +9,17 @@ minetest.register_node("watershed:appleleaf", { sounds = default.node_sound_leaves_defaults(), }) +minetest.register_node("watershed:acacialeaf", { + description = "WS Acacia Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_leaves.png"}, + paramtype = "light", + is_ground_content = false, + groups = {snappy=3, flammable=2, leaves=1}, + sounds = default.node_sound_leaves_defaults(), +}) + minetest.register_node("watershed:needles", { description = "WS Pine Needles", drawtype = "allfaces_optional", diff --git a/textures/watershed_bucketwater.png b/textures/watershed_bucketwater.png new file mode 100644 index 0000000000000000000000000000000000000000..57500d6b08bdda6332b7384158c505a1d911cc04 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggKW_b=Z`PctV`+-8IJY5_^EKZ-D zw3qjgfk5kgTNp(cgNv;k(p^48eq|`ShTX(rIhW~uO z_xHP+1M8hb&Q-29?fZ2j(9}9esj>G?{k#|n?PXG{V6ef zzfTBaVwe(S@lO8gvNSf~qajW{0-M%LrOXZWI{PDGRQpA59?cFE`?326!#O4Q VpNY@^oB{fZ!PC{xWt~$(6994}g0BDo literal 0 HcmV?d00001