forked from mtcontrib/watershed
Tune volcanos, lava flows again, no flagmask 0.4.9dev compatible
This commit is contained in:
parent
47c8204d4a
commit
cb732b1577
@ -1,4 +1,4 @@
|
|||||||
watershed 0.3.3 by paramat
|
watershed 0.3.4 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
|
@ -242,7 +242,7 @@ if SINGLENODE then
|
|||||||
-- Set mapgen parameters
|
-- Set mapgen parameters
|
||||||
|
|
||||||
minetest.register_on_mapgen_init(function(mgparams)
|
minetest.register_on_mapgen_init(function(mgparams)
|
||||||
minetest.set_mapgen_params({mgname="singlenode", flags = "nolight", flagmask = "nolight"})
|
minetest.set_mapgen_params({mgname="singlenode"})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Spawn player
|
-- Spawn player
|
||||||
@ -298,6 +298,22 @@ if SINGLENODE then
|
|||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.4
|
persist = 0.4
|
||||||
}
|
}
|
||||||
|
local np_temp = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=512, y=512, z=512},
|
||||||
|
seed = 9130,
|
||||||
|
octaves = 2,
|
||||||
|
persist = 0.5
|
||||||
|
}
|
||||||
|
local np_humid = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=512, y=512, z=512},
|
||||||
|
seed = -55500,
|
||||||
|
octaves = 2,
|
||||||
|
persist = 0.5
|
||||||
|
}
|
||||||
for chunk = 1, 32 do
|
for chunk = 1, 32 do
|
||||||
print ("[watershed] searching for spawn "..chunk)
|
print ("[watershed] searching for spawn "..chunk)
|
||||||
local x0 = 80 * math.random(-24, 24) - 32
|
local x0 = 80 * math.random(-24, 24) - 32
|
||||||
@ -315,6 +331,8 @@ if SINGLENODE then
|
|||||||
local nvals_rough = minetest.get_perlin_map(np_rough, 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_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_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minposxyz)
|
||||||
|
local nvals_temp = minetest.get_perlin_map(np_temp, chulens):get3dMap_flat(minposxyz)
|
||||||
|
local nvals_humid = minetest.get_perlin_map(np_humid, chulens):get3dMap_flat(minposxyz)
|
||||||
|
|
||||||
local nvals_base = minetest.get_perlin_map(np_base, 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 nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
|
||||||
@ -326,17 +344,19 @@ if SINGLENODE then
|
|||||||
for x = x0, x1 do
|
for x = x0, x1 do
|
||||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
||||||
local n_base = nvals_base[nixz]
|
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 densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
|
||||||
|
local terblen = math.max(1 - math.abs(n_base), 0)
|
||||||
|
local n_temp = nvals_temp[nixyz]
|
||||||
|
local n_humid = nvals_humid[nixyz]
|
||||||
local density
|
local density
|
||||||
if nvals_fault[nixyz] >= 0 then
|
if nvals_fault[nixyz] >= 0 then
|
||||||
density = densitybase
|
density = densitybase
|
||||||
+ math.abs(nvals_rough[nixyz] * terblen
|
+ math.abs(nvals_rough[nixyz] * terblen
|
||||||
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP
|
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_temp * 0.5)
|
||||||
else
|
else
|
||||||
density = densitybase
|
density = densitybase
|
||||||
+ math.abs(nvals_rough[nixyz] * terblen
|
+ math.abs(nvals_rough[nixyz] * terblen
|
||||||
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * 0.7
|
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_humid * 0.5)
|
||||||
end
|
end
|
||||||
if y >= 1 and density > -0.01 and density < 0 then
|
if y >= 1 and density > -0.01 and density < 0 then
|
||||||
ysp = y + 1
|
ysp = y + 1
|
||||||
|
72
init.lua
72
init.lua
@ -1,11 +1,11 @@
|
|||||||
-- watershed 0.3.3 by paramat
|
-- watershed 0.3.4 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
|
||||||
|
|
||||||
-- remove lavacooling abms
|
-- no flagmask for compatibility with 0.4.9dev
|
||||||
-- new appletree
|
-- tune volcanos
|
||||||
-- rivers continuous over faults
|
-- lava flows again
|
||||||
-- TODO
|
-- TODO
|
||||||
-- fog
|
-- fog
|
||||||
|
|
||||||
@ -28,7 +28,8 @@ local ATANAMP = 1.1 -- Arctan function amplitude, smaller = more and larger floa
|
|||||||
local TSTONE = 0.03 -- Density threshold for stone, depth of soil at TERCEN
|
local TSTONE = 0.03 -- Density threshold for stone, depth of soil at TERCEN
|
||||||
local TRIV = -0.02 -- Maximum densitybase threshold for river water
|
local TRIV = -0.02 -- Maximum densitybase threshold for river water
|
||||||
local TSAND = -0.025 -- Maximum densitybase threshold for river sand
|
local TSAND = -0.025 -- Maximum densitybase threshold for river sand
|
||||||
local TLAVA = 10 -- Maximum densitybase threshold for lava
|
local TLAVA = 2.5 -- Maximum densitybase threshold for lava, small because grad is non-linear
|
||||||
|
local VOLC = 0.5 -- Amount of volcanos
|
||||||
local FIST = 0 -- Fissure threshold at surface, controls size of fissure entrances at surface
|
local FIST = 0 -- Fissure threshold at surface, controls size of fissure entrances at surface
|
||||||
local FISEXP = 0.02 -- Fissure expansion rate under surface
|
local FISEXP = 0.02 -- Fissure expansion rate under surface
|
||||||
local ORETHI = 0.001 -- Ore seam thickness tuner
|
local ORETHI = 0.001 -- Ore seam thickness tuner
|
||||||
@ -211,35 +212,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local z0 = minp.z
|
local z0 = minp.z
|
||||||
|
|
||||||
print ("[watershed] chunk minp ("..x0.." "..y0.." "..z0..")")
|
print ("[watershed] chunk minp ("..x0.." "..y0.." "..z0..")")
|
||||||
|
-- voxelmanip stuff
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
-- make all nodes air except ores and strata, for testing
|
|
||||||
|
|
||||||
--local c_air = minetest.get_content_id("air")
|
|
||||||
--local c_water = minetest.get_content_id("air")
|
|
||||||
--local c_sand = minetest.get_content_id("air")
|
|
||||||
--local c_desand = minetest.get_content_id("air")
|
|
||||||
--local c_snowblock = minetest.get_content_id("air")
|
|
||||||
--local c_ice = minetest.get_content_id("air")
|
|
||||||
--local c_dirtsnow = minetest.get_content_id("air")
|
|
||||||
--local c_jungrass = minetest.get_content_id("air")
|
|
||||||
--local c_dryshrub = minetest.get_content_id("air")
|
|
||||||
--local c_clay = minetest.get_content_id("air")
|
|
||||||
|
|
||||||
--local c_wswater = minetest.get_content_id("air")
|
|
||||||
--local c_wsstone = minetest.get_content_id("air")
|
|
||||||
--local c_wsredstone = minetest.get_content_id("air")
|
|
||||||
--local c_wsgrass = minetest.get_content_id("air")
|
|
||||||
--local c_wsdrygrass = minetest.get_content_id("air")
|
|
||||||
--local c_wsgoldgrass = minetest.get_content_id("air")
|
|
||||||
--local c_wsdirt = minetest.get_content_id("air")
|
|
||||||
--local c_wscloud = minetest.get_content_id("air")
|
|
||||||
--local c_wsdarkcloud = minetest.get_content_id("air")
|
|
||||||
--local c_wspermafrost = minetest.get_content_id("air")
|
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
local c_sand = minetest.get_content_id("default:sand")
|
local c_sand = minetest.get_content_id("default:sand")
|
||||||
@ -278,7 +255,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local c_wsdarkcloud = minetest.get_content_id("watershed:darkcloud")
|
local c_wsdarkcloud = minetest.get_content_id("watershed:darkcloud")
|
||||||
local c_wspermafrost = minetest.get_content_id("watershed:permafrost")
|
local c_wspermafrost = minetest.get_content_id("watershed:permafrost")
|
||||||
local c_wslava = minetest.get_content_id("watershed:lava")
|
local c_wslava = minetest.get_content_id("watershed:lava")
|
||||||
|
-- perlinmap stuff
|
||||||
local sidelen = x1 - x0 + 1
|
local sidelen = x1 - x0 + 1
|
||||||
local chulens = {x=sidelen, y=sidelen+2, z=sidelen}
|
local chulens = {x=sidelen, y=sidelen+2, z=sidelen}
|
||||||
local minposxyz = {x=x0, y=y0-1, z=z0}
|
local minposxyz = {x=x0, y=y0-1, z=z0}
|
||||||
@ -302,25 +279,22 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if minetest.get_node({x=x0, y=y0-1, z=z0}).name == "ignore" then
|
if minetest.get_node({x=x0, y=y0-1, z=z0}).name == "ignore" then
|
||||||
ungen = true
|
ungen = true
|
||||||
end
|
end
|
||||||
|
-- mapgen loop
|
||||||
local nixyz = 1
|
local nixyz = 1
|
||||||
local nixz = 1
|
local nixz = 1
|
||||||
local stable = {}
|
local stable = {} -- stability table of true/false. is node stable and supported from below by stone or nodes on stone?
|
||||||
local under = {}
|
local under = {} -- biome table. biome number of previous fine material placed in column
|
||||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||||
for y = y0 - 1, y1 + 1 do -- for each x row progressing upwards
|
for y = y0 - 1, y1 + 1 do -- for each x row progressing upwards
|
||||||
local vi = area:index(x0, y, z)
|
local vi = area:index(x0, y, z)
|
||||||
local viu = area:index(x0, y-1, z)
|
local viu = area:index(x0, y-1, z)
|
||||||
for x = x0, x1 do -- for each node do
|
for x = x0, x1 do -- for each node do
|
||||||
local si = x - x0 + 1
|
local si = x - x0 + 1 -- stable, under tables index
|
||||||
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP
|
|
||||||
|
local grad = math.atan((TERCEN - y) / TERSCA) * ATANAMP -- get densitybase and density
|
||||||
local n_base = nvals_base[nixz]
|
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 densitybase = (1 - math.abs(n_base)) * BASAMP + nvals_xlscale[nixz] * XLSAMP + grad
|
||||||
local triv = TRIV * (1 - terblen)
|
local terblen = math.max(1 - math.abs(n_base), 0)
|
||||||
local tsand = TSAND * (1 - terblen)
|
|
||||||
local tstone = TSTONE * (1 + grad)
|
|
||||||
local tlava = TLAVA * (1 - nvals_magma[nixz] ^ 4 * terblen ^ 16)
|
|
||||||
local n_temp = nvals_temp[nixyz]
|
local n_temp = nvals_temp[nixyz]
|
||||||
local n_humid = nvals_humid[nixyz]
|
local n_humid = nvals_humid[nixyz]
|
||||||
local density
|
local density
|
||||||
@ -333,6 +307,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
+ math.abs(nvals_rough[nixyz] * terblen
|
+ math.abs(nvals_rough[nixyz] * terblen
|
||||||
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_humid * 0.5)
|
+ nvals_smooth[nixyz] * (1 - terblen)) ^ CANEXP * CANAMP * (1 + n_humid * 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local triv = TRIV * (1 - terblen) -- other values
|
||||||
|
local tsand = TSAND * (1 - terblen)
|
||||||
|
local tstone = TSTONE * (1 + grad)
|
||||||
|
local tlava = TLAVA * (1 - nvals_magma[nixz] ^ 4 * terblen ^ 16 * VOLC)
|
||||||
local nofis = false
|
local nofis = false
|
||||||
if density >= 0 then -- if terrain set fissure flag
|
if density >= 0 then -- if terrain set fissure flag
|
||||||
if math.abs(nvals_fissure[nixyz]) > FIST + math.sqrt(density) * FISEXP then
|
if math.abs(nvals_fissure[nixyz]) > FIST + math.sqrt(density) * FISEXP then
|
||||||
@ -390,13 +369,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if densitybase >= tlava then
|
if densitybase >= tlava then -- lava
|
||||||
if densitybase >= 0 then
|
if densitybase >= 0 then
|
||||||
data[vi] = c_wslava
|
data[vi] = c_wslava
|
||||||
end
|
end
|
||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
under[si] = 0
|
under[si] = 0
|
||||||
elseif densitybase >= tlava - math.min(2 + density * 20, 2) and density < tstone then
|
elseif densitybase >= tlava - math.min(1 + density * 10, 1) and density < tstone then -- obsidian
|
||||||
data[vi] = c_obsidian
|
data[vi] = c_obsidian
|
||||||
stable[si] = 1
|
stable[si] = 1
|
||||||
under[si] = 0
|
under[si] = 0
|
||||||
@ -635,11 +614,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
nixz = nixz + 80
|
nixz = nixz + 80
|
||||||
end
|
end
|
||||||
|
-- voxelmanip stuff
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
-- vm:set_lighting({day=0, night=0})
|
vm:set_lighting({day=0, night=0})
|
||||||
vm:calc_lighting()
|
vm:calc_lighting()
|
||||||
vm:write_to_map(data)
|
vm:write_to_map(data)
|
||||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
|
||||||
|
local chugent = math.ceil((os.clock() - t1) * 1000) -- chunk generation time
|
||||||
print ("[watershed] "..chugent.." ms")
|
print ("[watershed] "..chugent.." ms")
|
||||||
end)
|
end)
|
@ -274,7 +274,7 @@ minetest.register_node("watershed:lava", {
|
|||||||
liquid_alternative_source = "watershed:lava",
|
liquid_alternative_source = "watershed:lava",
|
||||||
liquid_viscosity = LAVA_VISC,
|
liquid_viscosity = LAVA_VISC,
|
||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
liquid_range = 0,
|
liquid_range = 2,
|
||||||
damage_per_second = 8,
|
damage_per_second = 8,
|
||||||
post_effect_color = {a=192, r=255, g=64, b=0},
|
post_effect_color = {a=192, r=255, g=64, b=0},
|
||||||
groups = {lava=3, liquid=2, hot=3, igniter=1},
|
groups = {lava=3, liquid=2, hot=3, igniter=1},
|
||||||
@ -313,7 +313,7 @@ minetest.register_node("watershed:lavaflow", {
|
|||||||
liquid_alternative_source = "watershed:lava",
|
liquid_alternative_source = "watershed:lava",
|
||||||
liquid_viscosity = LAVA_VISC,
|
liquid_viscosity = LAVA_VISC,
|
||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
liquid_range = 0,
|
liquid_range = 2,
|
||||||
damage_per_second = 8,
|
damage_per_second = 8,
|
||||||
post_effect_color = {a=192, r=255, g=64, b=0},
|
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},
|
groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},
|
||||||
|
Loading…
Reference in New Issue
Block a user