diff --git a/README.txt b/README.txt index 8d99a52..a3a52e7 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -watershed 0.3.0 by paramat +watershed 0.3.1 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 0a6863d..56af3f2 100644 --- a/functions.lua +++ b/functions.lua @@ -249,137 +249,143 @@ minetest.register_abm({ end, }) --- Set mapgen parameters +-- Singlenode mapgen option -minetest.register_on_mapgen_init(function(mgparams) - minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"}) -end) +local SINGLENODE = true --- Spawn player +if SINGLENODE then + -- Set mapgen parameters -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, 32 do - print ("[watershed] chunk "..chunk) - local x0 = 80 * math.random(-24, 24) - 32 - local z0 = 80 * math.random(-24, 24) - 32 - local y0 = -32 - local x1 = x0 + 79 - local z1 = z0 + 79 - local y1 = 47 + 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, 32 do + print ("[watershed] chunk "..chunk) + local x0 = 80 * math.random(-24, 24) - 32 + local z0 = 80 * math.random(-24, 24) - 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 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_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 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 + 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 + xsp = x + zsp = z + break + end + nixz = nixz + 1 + nixyz = nixyz + 1 end - if y >= 1 and density > -0.01 and density < 0 then - ysp = y - xsp = x - zsp = z + if ysp then break end - nixz = nixz + 1 - nixyz = nixyz + 1 + nixz = nixz - 80 end if ysp then break end - nixz = nixz - 80 + nixz = nixz + 80 end if ysp then break end - nixz = nixz + 80 - end - if ysp then - break end + print ("[watershed] spawn player ("..xsp.." "..ysp.." "..zsp..")") + player:setpos({x=xsp, y=ysp, z=zsp}) end - print ("[watershed] spawn player ("..xsp.." "..ysp.." "..zsp..")") - player:setpos({x=xsp, y=ysp, z=zsp}) -end -minetest.register_on_newplayer(function(player) - spawnplayer(player) -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 + minetest.register_on_respawnplayer(function(player) + spawnplayer(player) + return true + end) +end \ No newline at end of file diff --git a/init.lua b/init.lua index e40563e..6fa6def 100644 --- a/init.lua +++ b/init.lua @@ -1,11 +1,14 @@ --- watershed 0.3.0 by paramat +-- watershed 0.3.1 by paramat -- For latest stable Minetest and back to 0.4.8 -- Depends default -- License: code WTFPL --- add snowy plains biome +-- bugfixes +-- optional mod clouds +-- stacked realm / singlenode option +-- volcanoes -- TODO --- lava at surface: volcanic cone? +-- check river continuous over faults -- tree heights vary -- fog @@ -16,6 +19,7 @@ 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 CLOUDS = false local TERSCA = 512 -- Vertical terrain scale local XLSAMP = 0.2 -- Extra large scale height variation amplitude @@ -24,7 +28,7 @@ local CANAMP = 0.4 -- Canyon terrain amplitude local CANEXP = 1.33 -- Canyon shape exponent local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floatlands above ridges -local TSTONE = 0.01 -- Density threshold for stone, depth of soil at TERCEN +local TSTONE = 0.02 -- 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 = 2 -- Maximum densitybase threshold for lava @@ -34,16 +38,16 @@ local ORETHI = 0.001 -- Ore seam thickness tuner local ORET = 0.02 -- Ore threshold for seam local TCLOUD = 0.5 -- Cloud threshold -local HITET = 0.4 -- High temperature threshold -local LOTET = -0.4 -- Low .. -local ICETET = -0.8 -- Ice .. -local HIHUT = 0.4 -- High humidity threshold -local LOHUT = -0.4 -- Low .. +local HITET = 0.35 -- High temperature threshold +local LOTET = -0.35 -- Low .. +local ICETET = -0.7 -- Ice .. +local HIHUT = 0.35 -- High humidity threshold +local LOHUT = -0.35 -- Low .. local CLOHUT = 0 -- Cloud humidity threshold local DCLOHUT = 1 -- Dark cloud .. -local PINCHA = 47 -- Pine tree 1/x chance per node -local APTCHA = 47 -- Appletree +local PINCHA = 49 -- Pine tree 1/x chance per node +local APTCHA = 49 -- Appletree local FLOCHA = 36 -- Flower local FOGCHA = 9 -- Forest grass local GRACHA = 3 -- Grassland grasses @@ -52,7 +56,7 @@ local JUGCHA = 9 -- Junglegrass local CACCHA = 841 -- Cactus local DRYCHA = 169 -- Dry shrub local PAPCHA = 3 -- Papyrus -local ACACHA = 841 -- Acacia tree +local ACACHA = 529 -- Acacia tree local GOGCHA = 3 -- Golden grass -- 3D noise for rough terrain @@ -183,7 +187,7 @@ local np_magma = { scale = 1, spread = {x=128, y=128, z=128}, seed = -13, - octaves = 1, + octaves = 2, persist = 0.5 } @@ -264,6 +268,7 @@ minetest.register_on_generated(function(minp, maxp, seed) local c_gravel = minetest.get_content_id("default:gravel") local c_clay = minetest.get_content_id("default:clay") local c_grass5 = minetest.get_content_id("default:grass_5") + local c_obsidian = minetest.get_content_id("default:obsidian") local c_wswater = minetest.get_content_id("watershed:water") local c_wsstone = minetest.get_content_id("watershed:stone") @@ -316,10 +321,10 @@ minetest.register_on_generated(function(minp, maxp, seed) local terblen = math.max(1 - math.abs(n_base), 0) local densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad local altprop = (y - YWAT) / (TERCEN + TERSCA - YWAT) - local triv = TRIV * (1 - altprop * 1.1) - local tsand = TSAND * (1 - altprop * 1.1) + local triv = TRIV * (1 - terblen) + local tsand = TSAND * (1 - terblen * 1.1) local tstone = TSTONE * (1 - math.atan(altprop) * 0.6) -- 1 to 0.05 - local tlava = TLAVA * (0.9 - nvals_magma[nixz] ^ 4 * terblen ^ 16) + local tlava = TLAVA * (1 - nvals_magma[nixz] ^ 4 * terblen ^ 16) local density if nvals_fault[nixyz] >= 0 then density = densitybase @@ -389,10 +394,16 @@ minetest.register_on_generated(function(minp, maxp, seed) end end - if density >= tstone and densitybase >= tlava then - data[vi] = c_wslava + if densitybase >= tlava then + if densitybase >= -0.05 then + data[vi] = c_wslava + end stable[si] = 0 under[si] = 0 + elseif densitybase >= tlava - 0.5 and densitybase >= -0.1 then + data[vi] = c_obsidian + stable[si] = 1 + under[si] = 0 elseif density >= tstone and nofis -- stone cut by fissures or (density >= tstone and density < TSTONE * 3 and y <= YWAT) -- stone around water or (density >= tstone and density < TSTONE * 3 and densitybase >= triv ) then -- stone around river @@ -495,7 +506,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end stable[si] = 0 under[si] = 0 - elseif y == YCLOUD then -- clouds + elseif CLOUDS and y == YCLOUD then -- clouds local xrq = 16 * math.floor((x - x0) / 16) -- quantise to 16x16 lattice local zrq = 16 * math.floor((z - z0) / 16) local qixz = zrq * 80 + xrq + 1 -- quantised index @@ -604,16 +615,18 @@ minetest.register_on_generated(function(minp, maxp, seed) end elseif under[si] == 2 then data[viu] = c_dirtsnow + elseif under[si] == 3 then + data[viu] = c_dirtsnow + elseif under[si] == 4 then + data[viu] = c_wsdrygrass elseif under[si] == 5 then data[viu] = c_wsgrass - elseif under[si] == 3 then - data[viu] = c_wsdrygrass - elseif under[si] == 4 then + elseif under[si] == 6 then data[viu] = c_wsgrass elseif under[si] == 8 then - data[viu] = c_wsgrass - elseif under[si] == 7 then data[viu] = c_wsdrygrass + elseif under[si] == 9 then + data[viu] = c_wsgrass end end end diff --git a/nodes.lua b/nodes.lua index 73642e0..df73879 100644 --- a/nodes.lua +++ b/nodes.lua @@ -274,7 +274,7 @@ minetest.register_node("watershed:lava", { liquid_alternative_source = "watershed:lava", liquid_viscosity = LAVA_VISC, liquid_renewable = false, - liquid_range = 2, + liquid_range = 0, damage_per_second = 8, post_effect_color = {a=192, r=255, g=64, b=0}, groups = {lava=3, liquid=2, hot=3, igniter=1}, @@ -313,7 +313,7 @@ minetest.register_node("watershed:lavaflow", { liquid_alternative_source = "watershed:lava", liquid_viscosity = LAVA_VISC, liquid_renewable = false, - liquid_range = 2, + liquid_range = 0, damage_per_second = 8, post_effect_color = {a=192, r=255, g=64, b=0}, groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},