Remove realm limits, fix lighting outside limits. Spawnplayer function: create noise objects only once, move to init.lua. New LGPL, CC BY-SA licenses. Improve code style. Add info to readme
This commit is contained in:
parent
6623438509
commit
68409fa5cf
13
README.txt
13
README.txt
@ -1,6 +1,9 @@
|
|||||||
riverdev 0.7.2 by paramat
|
riverdev 0.7.3 by paramat
|
||||||
For latest stable Minetest back to 0.4.8
|
For Minetest 0.4.12 and later
|
||||||
Depends default
|
Depends default stairs bucket
|
||||||
Licenses: code WTFPL
|
Licenses: Code LGPL 2.1, textures CC BY-SA
|
||||||
|
|
||||||
Update spawnplayer function, 2D perlinmap z-size = 1.
|
This mod is my 'watershed' mapgen (https://forum.minetest.net/viewtopic.php?f=11&t=8609) with fewer biomes, 2 path/bridge networks, tunnels/fissures/caves, boulders, improved magma channels and mini-volcanos.
|
||||||
|
The mod will automatically select 'singlenode' mapgen and will spawn players at the surface but also scattered up to 1280n from world centre
|
||||||
|
To make your first torches search for coal in tunnel entrances, near sea level or rivers these entrances are sometimes sealed by stone (result of protecting against underground flooding).
|
||||||
|
Ores are a few nodes underground to prevent easy surface mining in the rocky mountains.
|
||||||
|
145
functions.lua
145
functions.lua
@ -376,148 +376,3 @@ minetest.register_abm({
|
|||||||
vm:update_map()
|
vm:update_map()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set mapgen parameters
|
|
||||||
|
|
||||||
minetest.register_on_mapgen_init(function(mgparams)
|
|
||||||
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Spawn player. Only works with chunksize = 5 mapblocks
|
|
||||||
|
|
||||||
function spawnplayer(player)
|
|
||||||
local PSCA = 16 -- Player scatter. Maximum distance in chunks (80 nodes) of player spawn from (0, 0, 0)
|
|
||||||
local YWATER = 1
|
|
||||||
local YTER = -64 -- Deepest seabed y
|
|
||||||
local TERSCA = 512 -- Terrain vertical scale in nodes
|
|
||||||
local BASAMP = 0.3 -- Base amplitude relative to 3D noise amplitude. Ridge network structure
|
|
||||||
local MIDAMP = 0.05 -- Mid amplitude relative to 3D noise amplitude. River valley structure
|
|
||||||
|
|
||||||
local np_terrain = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=384, y=192, z=384},
|
|
||||||
seed = 5900033,
|
|
||||||
octaves = 5,
|
|
||||||
persist = 0.67
|
|
||||||
}
|
|
||||||
local np_mid = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=1536, y=1536, z=1536},
|
|
||||||
seed = 85546,
|
|
||||||
octaves = 6,
|
|
||||||
persist = 0.4
|
|
||||||
}
|
|
||||||
local np_base = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=3072, y=3072, z=3072},
|
|
||||||
seed = -990054,
|
|
||||||
octaves = 3,
|
|
||||||
persist = 0.4
|
|
||||||
}
|
|
||||||
local np_patha = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=768, y=768, z=768},
|
|
||||||
seed = 7000023,
|
|
||||||
octaves = 4,
|
|
||||||
persist = 0.4
|
|
||||||
}
|
|
||||||
local np_pathb = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=768, y=768, z=768},
|
|
||||||
seed = 23,
|
|
||||||
octaves = 4,
|
|
||||||
persist = 0.4
|
|
||||||
}
|
|
||||||
|
|
||||||
local xsp
|
|
||||||
local ysp
|
|
||||||
local zsp
|
|
||||||
for chunk = 1, 128 do
|
|
||||||
print ("[riverdev] searching for spawn "..chunk)
|
|
||||||
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
|
||||||
local z0 = 80 * math.random(-PSCA, PSCA) - 32
|
|
||||||
local y0 = 80 * math.floor((YWATER + 32) / 80) - 32
|
|
||||||
local x1 = x0 + 79
|
|
||||||
local z1 = z0 + 79
|
|
||||||
local y1 = y0 + 79
|
|
||||||
|
|
||||||
local sidelen = 80
|
|
||||||
local chulensxyz = {x=sidelen, y=sidelen, z=sidelen}
|
|
||||||
local minposxyz = {x=x0, y=y0, z=z0}
|
|
||||||
local chulensxz = {x=sidelen, y=sidelen, z=1}
|
|
||||||
local minposxz = {x=x0, y=z0}
|
|
||||||
|
|
||||||
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulensxyz):get3dMap_flat(minposxyz)
|
|
||||||
|
|
||||||
local nvals_mid = minetest.get_perlin_map(np_mid, chulensxz):get2dMap_flat(minposxz)
|
|
||||||
local nvals_base = minetest.get_perlin_map(np_base, 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 nixyz = 1
|
|
||||||
local nixz = 1
|
|
||||||
for z = z0, z1 do
|
|
||||||
for y = y0, y1 do
|
|
||||||
for x = x0, x1 do
|
|
||||||
local n_patha = nvals_patha[nixz]
|
|
||||||
local n_abspatha = math.abs(n_patha)
|
|
||||||
local n_pathb = nvals_pathb[nixz]
|
|
||||||
local n_abspathb = math.abs(n_pathb)
|
|
||||||
|
|
||||||
local n_terrain = (nvals_terrain[nixyz] + 2) / 2
|
|
||||||
local n_absmid = (math.abs(nvals_mid[nixz])) ^ 0.8
|
|
||||||
local n_absbase = (math.abs(nvals_base[nixz])) ^ 0.8
|
|
||||||
local n_invbase = math.max(1 - n_absbase, 0)
|
|
||||||
|
|
||||||
local grad = (YTER - y) / TERSCA
|
|
||||||
local densitybase = n_invbase * BASAMP + grad
|
|
||||||
local densitymid = n_absmid * MIDAMP + densitybase
|
|
||||||
local density = n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5
|
|
||||||
+ densitymid
|
|
||||||
|
|
||||||
if y >= YWATER and density > -0.01 and density < 0 then
|
|
||||||
ysp = y + 1
|
|
||||||
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
|
|
||||||
if ysp then
|
|
||||||
print ("[riverdev] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
|
||||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
|
||||||
else
|
|
||||||
print ("[riverdev] no suitable spawn found")
|
|
||||||
player:setpos({x=0, y=2, z=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_newplayer(function(player)
|
|
||||||
spawnplayer(player)
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
|
||||||
spawnplayer(player)
|
|
||||||
return true
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
164
init.lua
164
init.lua
@ -1,7 +1,8 @@
|
|||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local YMIN = -33000 -- Y limits of realm generation
|
local PSCA = 16 -- Player scatter. Maximum distance in chunks (80 nodes)
|
||||||
local YMAX = 1024
|
-- of player spawn from (0, 0, 0)
|
||||||
|
|
||||||
local YWATER = 1 -- Water surface y
|
local YWATER = 1 -- Water surface y
|
||||||
local YSAND = 4 -- Top of beach y
|
local YSAND = 4 -- Top of beach y
|
||||||
local YTER = -64 -- Deepest seabed y
|
local YTER = -64 -- Deepest seabed y
|
||||||
@ -209,31 +210,20 @@ local np_strata = {
|
|||||||
persist = 1
|
persist = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stuff
|
|
||||||
|
|
||||||
-- initialize 3D and 2D noise objects to nil
|
-- Do files
|
||||||
|
|
||||||
local nobj_terrain = nil
|
|
||||||
local nobj_terrainalt = nil
|
|
||||||
local nobj_temp = nil
|
|
||||||
local nobj_weba = nil
|
|
||||||
local nobj_webb = nil
|
|
||||||
local nobj_webc = nil
|
|
||||||
local nobj_webd = nil
|
|
||||||
local nobj_webe = nil
|
|
||||||
local nobj_fissure = nil
|
|
||||||
local nobj_strata = nil
|
|
||||||
|
|
||||||
local nobj_mid = nil
|
|
||||||
local nobj_base = nil
|
|
||||||
local nobj_patha = nil
|
|
||||||
local nobj_pathb = nil
|
|
||||||
local nobj_tree = nil
|
|
||||||
local nobj_grass = nil
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("riverdev") .. "/functions.lua")
|
dofile(minetest.get_modpath("riverdev") .. "/functions.lua")
|
||||||
dofile(minetest.get_modpath("riverdev") .. "/nodes.lua")
|
dofile(minetest.get_modpath("riverdev") .. "/nodes.lua")
|
||||||
|
|
||||||
|
|
||||||
|
-- Set mapgen parameters
|
||||||
|
|
||||||
|
minetest.register_on_mapgen_init(function(mgparams)
|
||||||
|
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Mapgen functions
|
-- Mapgen functions
|
||||||
|
|
||||||
local function riverdev_pathbrush(x, y, z, area, data,
|
local function riverdev_pathbrush(x, y, z, area, data,
|
||||||
@ -349,13 +339,31 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- initialize noise objects to nil
|
||||||
|
|
||||||
|
local nobj_terrain = nil
|
||||||
|
local nobj_terrainalt = nil
|
||||||
|
local nobj_temp = nil
|
||||||
|
local nobj_weba = nil
|
||||||
|
local nobj_webb = nil
|
||||||
|
local nobj_webc = nil
|
||||||
|
local nobj_webd = nil
|
||||||
|
local nobj_webe = nil
|
||||||
|
local nobj_fissure = nil
|
||||||
|
local nobj_strata = nil
|
||||||
|
|
||||||
|
local nobj_mid = nil
|
||||||
|
local nobj_base = nil
|
||||||
|
local nobj_patha = nil
|
||||||
|
local nobj_pathb = nil
|
||||||
|
local nobj_tree = nil
|
||||||
|
local nobj_grass = nil
|
||||||
|
|
||||||
|
|
||||||
-- On generated function
|
-- On generated function
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if minp.y < YMIN or maxp.y > YMAX then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local t0 = os.clock()
|
local t0 = os.clock()
|
||||||
local x1 = maxp.x
|
local x1 = maxp.x
|
||||||
local y1 = maxp.y
|
local y1 = maxp.y
|
||||||
@ -364,8 +372,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local y0 = minp.y
|
local y0 = minp.y
|
||||||
local z0 = minp.z
|
local z0 = minp.z
|
||||||
|
|
||||||
print ("[riverdev] generate chunk minp ("..x0.." "..y0.." "..z0..")")
|
|
||||||
|
|
||||||
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()
|
||||||
@ -723,3 +729,105 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
print ("[riverdev] " .. chugent .. " ms")
|
print ("[riverdev] " .. chugent .. " ms")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- Spawn player function
|
||||||
|
-- Only works with chunksize = 5 mapblocks
|
||||||
|
|
||||||
|
local function riverdev_spawnplayer(player)
|
||||||
|
local xsp
|
||||||
|
local ysp
|
||||||
|
local zsp
|
||||||
|
local nobj_terrain = nil
|
||||||
|
local nobj_mid = nil
|
||||||
|
local nobj_base = nil
|
||||||
|
local nobj_patha = nil
|
||||||
|
local nobj_pathb = nil
|
||||||
|
|
||||||
|
for chunk = 1, 128 do
|
||||||
|
print ("[riverdev] searching for spawn " .. chunk)
|
||||||
|
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||||
|
local z0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||||
|
local y0 = 80 * math.floor((YWATER + 32) / 80) - 32
|
||||||
|
local x1 = x0 + 79
|
||||||
|
local z1 = z0 + 79
|
||||||
|
local y1 = y0 + 79
|
||||||
|
|
||||||
|
local sidelen = 80
|
||||||
|
local chulensxyz = {x = sidelen, y = sidelen, z = sidelen}
|
||||||
|
local minposxyz = {x = x0, y = y0, z = z0}
|
||||||
|
local chulensxz = {x = sidelen, y = sidelen, z = 1}
|
||||||
|
local minposxz = {x = x0, y = z0}
|
||||||
|
|
||||||
|
nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, chulensxyz)
|
||||||
|
nobj_mid = nobj_mid or minetest.get_perlin_map(np_mid, chulensxz)
|
||||||
|
nobj_base = nobj_base or minetest.get_perlin_map(np_base, chulensxz)
|
||||||
|
nobj_patha = nobj_patha or minetest.get_perlin_map(np_patha, chulensxz)
|
||||||
|
nobj_pathb = nobj_pathb or minetest.get_perlin_map(np_pathb, chulensxz)
|
||||||
|
|
||||||
|
local nvals_terrain = nobj_terrain:get3dMap_flat(minposxyz)
|
||||||
|
local nvals_mid = nobj_mid:get2dMap_flat(minposxz)
|
||||||
|
local nvals_base = nobj_base:get2dMap_flat(minposxz)
|
||||||
|
local nvals_patha = nobj_patha:get2dMap_flat(minposxz)
|
||||||
|
local nvals_pathb = nobj_pathb:get2dMap_flat(minposxz)
|
||||||
|
|
||||||
|
local nixyz = 1
|
||||||
|
local nixz = 1
|
||||||
|
for z = z0, z1 do
|
||||||
|
for y = y0, y1 do
|
||||||
|
for x = x0, x1 do
|
||||||
|
local n_patha = nvals_patha[nixz]
|
||||||
|
local n_abspatha = math.abs(n_patha)
|
||||||
|
local n_pathb = nvals_pathb[nixz]
|
||||||
|
local n_abspathb = math.abs(n_pathb)
|
||||||
|
|
||||||
|
local n_terrain = (nvals_terrain[nixyz] + 2) / 2
|
||||||
|
local n_absmid = (math.abs(nvals_mid[nixz])) ^ 0.8
|
||||||
|
local n_absbase = (math.abs(nvals_base[nixz])) ^ 0.8
|
||||||
|
local n_invbase = math.max(1 - n_absbase, 0)
|
||||||
|
|
||||||
|
local grad = (YTER - y) / TERSCA
|
||||||
|
local densitybase = n_invbase * BASAMP + grad
|
||||||
|
local densitymid = n_absmid * MIDAMP + densitybase
|
||||||
|
local density = n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5
|
||||||
|
+ densitymid
|
||||||
|
|
||||||
|
if y >= YWATER and density > -0.01 and density < 0 then
|
||||||
|
ysp = y + 1
|
||||||
|
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
|
||||||
|
if ysp then
|
||||||
|
print ("[riverdev] spawn player (" .. xsp .. " " .. ysp .. " " .. zsp .. ")")
|
||||||
|
player:setpos({x = xsp, y = ysp, z = zsp})
|
||||||
|
else
|
||||||
|
print ("[riverdev] no suitable spawn found")
|
||||||
|
player:setpos({x = 0, y = 2, z = 0})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
riverdev_spawnplayer(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
riverdev_spawnplayer(player)
|
||||||
|
return true
|
||||||
|
end)
|
||||||
|
29
license.txt
29
license.txt
@ -1,14 +1,25 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
License of source code
|
||||||
Version 2, December 2004
|
----------------------
|
||||||
|
Copyright (C) 2014-2015 paramat.
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
This program is distributed in the hope that it will be useful,
|
||||||
copies of this license document, and changing it is allowed as long
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
as the name is changed.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
You should have received a copy of the GNU Lesser General Public License along
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
License of media (textures)
|
||||||
|
---------------------------
|
||||||
|
All textures are derived from Minetest's default textures.
|
||||||
|
|
||||||
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ minetest.register_node("riverdev:appling", {
|
|||||||
|
|
||||||
minetest.register_node("riverdev:pinetree", {
|
minetest.register_node("riverdev:pinetree", {
|
||||||
description = "Pine tree",
|
description = "Pine tree",
|
||||||
tiles = {"riverdev_pinetreetop.png", "riverdev_pinetreetop.png", "riverdev_pinetree.png"},
|
tiles = {"riverdev_pinetreetop.png", "riverdev_pinetreetop.png",
|
||||||
|
"riverdev_pinetree.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||||
@ -185,7 +186,8 @@ minetest.register_node("riverdev:jungling", {
|
|||||||
|
|
||||||
minetest.register_node("riverdev:acaciatree", {
|
minetest.register_node("riverdev:acaciatree", {
|
||||||
description = "Acacia tree",
|
description = "Acacia tree",
|
||||||
tiles = {"riverdev_acaciatreetop.png", "riverdev_acaciatreetop.png", "riverdev_acaciatree.png"},
|
tiles = {"riverdev_acaciatreetop.png", "riverdev_acaciatreetop.png",
|
||||||
|
"riverdev_acaciatree.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||||
@ -494,4 +496,3 @@ bucket.register_liquid(
|
|||||||
"riverdev_bucketfreshwater.png",
|
"riverdev_bucketfreshwater.png",
|
||||||
"Fresh Water Bucket"
|
"Fresh Water Bucket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user