Fix no light above 288. Spawnplayer function: optimise noise and move to init.lua. Make slabs not buildable-to. Add 'is ground content' lines. Add missing spaces. Shorten lines. Add info to readme
This commit is contained in:
parent
c536b9c2c9
commit
b06e40a5ed
24
README.txt
24
README.txt
@ -1,16 +1,18 @@
|
|||||||
noisegrid 0.3.10 by paramat
|
noisegrid 0.4.0 by paramat
|
||||||
For Minetest 0.4.12 and later
|
For Minetest 0.4.12 and later
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: Code LGPL 2.1, textures CC BY-SA
|
Licenses: Code LGPL 2.1, textures CC BY-SA
|
||||||
|
|
||||||
|
For use with 'singlenode' mapgen.
|
||||||
|
City street grid areas, coastal intercity roads, tunnel roads, 2 dirt paths, wooden bridges over fissures.
|
||||||
|
Underground fissure system.
|
||||||
|
All default ores.
|
||||||
|
White lines, raised half-slab pavements.
|
||||||
|
Mountains up to y = 256.
|
||||||
|
Tree, grass and flower areas with varying density.
|
||||||
|
Mod's own appletree drops saplings that are grown by voxelmanip.
|
||||||
|
Overgeneration is used in x and z axes for continuous roads and paths over chunk borders.
|
||||||
|
|
||||||
Version changes:
|
Spawnplayer function randomly searches a large area for land to spawn players on.
|
||||||
|
Players are spawned scattered up to 1280 nodes from world centre.
|
||||||
flags="nolight" instead of set_lighting()
|
The player scatter from world centre can be set by parameter 'PSCA' in the functions.lua file, since oceans can be up to 2kn across searches will fail when PSCA is set too small.
|
||||||
paramtype="light" to spread light source light
|
|
||||||
add vm:update_liquids
|
|
||||||
remove light spread ABMs and dummy light source nodes
|
|
||||||
2D perlinmap Z-size = 1
|
|
||||||
create noise objects only once
|
|
||||||
new LGPL/CC BY-SA licences
|
|
||||||
|
|
||||||
|
@ -101,87 +101,3 @@ minetest.register_abm({
|
|||||||
vm:update_map()
|
vm:update_map()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Spawn player
|
|
||||||
|
|
||||||
function spawnplayer(player)
|
|
||||||
-- Parameters
|
|
||||||
local PSCA = 16 -- Player scatter. Maximum distance in chunks (80 nodes) of player spawn from (0, 0, 0)
|
|
||||||
local YFLAT = 7 -- Flat area elevation
|
|
||||||
local TERSCA = 192 -- Vertical terrain scale
|
|
||||||
local TFLAT = 0.2 -- Flat area width
|
|
||||||
|
|
||||||
local xsp
|
|
||||||
local ysp
|
|
||||||
local zsp
|
|
||||||
local np_base = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=2048, y=2048, z=2048},
|
|
||||||
seed = -9111,
|
|
||||||
octaves = 6,
|
|
||||||
persist = 0.6
|
|
||||||
}
|
|
||||||
for chunk = 1, 128 do
|
|
||||||
print ("[noisegrid] searching for spawn "..chunk)
|
|
||||||
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
|
||||||
local z0 = 80 * math.random(-PSCA, PSCA) - 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 minposxz = {x=x0, y=z0}
|
|
||||||
|
|
||||||
local nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz)
|
|
||||||
|
|
||||||
local nixz = 1
|
|
||||||
for z = z0, z1 do
|
|
||||||
for x = x0, x1 do
|
|
||||||
local ysurf
|
|
||||||
local n_base = nvals_base[nixz]
|
|
||||||
local n_absbase = math.abs(n_base)
|
|
||||||
if n_base > TFLAT then
|
|
||||||
ysurf = YFLAT + math.floor((n_base - TFLAT) * TERSCA)
|
|
||||||
elseif n_base < -TFLAT then
|
|
||||||
ysurf = YFLAT - math.floor((-TFLAT - n_base) * TERSCA)
|
|
||||||
else
|
|
||||||
ysurf = YFLAT
|
|
||||||
end
|
|
||||||
if ysurf >= 1 then
|
|
||||||
ysp = ysurf + 1
|
|
||||||
xsp = x
|
|
||||||
zsp = z
|
|
||||||
break
|
|
||||||
end
|
|
||||||
nixz = nixz + 1
|
|
||||||
end
|
|
||||||
if ysp then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if ysp then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if ysp then
|
|
||||||
print ("[noisegrid] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
|
||||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
|
||||||
else
|
|
||||||
print ("[noisegrid] 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)
|
|
||||||
|
|
||||||
|
93
init.lua
93
init.lua
@ -6,15 +6,19 @@ local TERSCA = 192 -- Vertical terrain scale in nodes
|
|||||||
local STODEP = 5 -- Stone depth below surface in nodes at sea level
|
local STODEP = 5 -- Stone depth below surface in nodes at sea level
|
||||||
local TGRID = 0.18 -- City grid area width
|
local TGRID = 0.18 -- City grid area width
|
||||||
local TFLAT = 0.2 -- Flat coastal area width
|
local TFLAT = 0.2 -- Flat coastal area width
|
||||||
local TCITY = 0 -- City size. 0.3 = 1/3 of coastal land area, 0 = 1/2 of coastal land area
|
local TCITY = 0 -- City size.
|
||||||
|
-- 0.3 = 1/3 of coastal land area, 0 = 1/2 of coastal land area.
|
||||||
local TFIS = 0.01 -- Fissure width
|
local TFIS = 0.01 -- Fissure width
|
||||||
local TTUN = 0.02 -- Tunnel width
|
local TTUN = 0.02 -- Tunnel width
|
||||||
local LUXCHA = 1 / 9 ^ 3 -- Luxore chance per stone node.
|
local LUXCHA = 1 / 9 ^ 3 -- Luxore chance per stone node.
|
||||||
local ORECHA = 1 / 5 ^ 3 -- Ore chance per stone node. 1 / n ^ 3 where n = average distance between ores
|
local ORECHA = 1 / 5 ^ 3 -- Ore chance per stone node.
|
||||||
local APPCHA = 1 / 4 ^ 2 -- Appletree maximum chance per grass node. 1 / n ^ 2 where n = minimum average distance between flora
|
-- 1 / n ^ 3 where n = average distance between ores.
|
||||||
|
local APPCHA = 1 / 4 ^ 2 -- Appletree maximum chance per grass node.
|
||||||
|
-- 1 / n ^ 2 where n = minimum average distance between flora.
|
||||||
local FLOCHA = 1 / 13 ^ 2 -- Flowers maximum chance per grass node
|
local FLOCHA = 1 / 13 ^ 2 -- Flowers maximum chance per grass node
|
||||||
local GRACHA = 1 / 5 ^ 2 -- Grasses maximum chance per grass node
|
local GRACHA = 1 / 5 ^ 2 -- Grasses maximum chance per grass node
|
||||||
|
local PSCA = 16 -- Player scatter. Maximum distance in chunks (80 nodes)
|
||||||
|
-- of player spawn points from (0, 0, 0).
|
||||||
|
|
||||||
-- 2D noise for base terrain
|
-- 2D noise for base terrain
|
||||||
|
|
||||||
@ -192,10 +196,6 @@ local nobj_webc = 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 > 208 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
local x1 = maxp.x
|
local x1 = maxp.x
|
||||||
local y1 = maxp.y
|
local y1 = maxp.y
|
||||||
@ -316,7 +316,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
|
|
||||||
local n_fissure = nvals_fissure[nixyz]
|
local n_fissure = nvals_fissure[nixyz]
|
||||||
local n_absfissure = math.abs(n_fissure)
|
local n_absfissure = math.abs(n_fissure)
|
||||||
local nofis = n_absfissure > TFIS and not (weba and webb) and not (weba and webc)
|
local nofis = n_absfissure > TFIS and
|
||||||
|
not (weba and webb) and not (weba and webc)
|
||||||
local wood = n_absfissure < TFIS * 2 and not flat
|
local wood = n_absfissure < TFIS * 2 and not flat
|
||||||
|
|
||||||
local n_city = nvals_city[nixz]
|
local n_city = nvals_city[nixz]
|
||||||
@ -598,6 +599,78 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
vm:update_liquids()
|
vm:update_liquids()
|
||||||
|
|
||||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||||
print ("[noisegrid] chunk ("..x0.." "..y0.." "..z0..") "..chugent.." ms")
|
print ("[noisegrid] " .. chugent .. " ms")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- Spawn player function
|
||||||
|
|
||||||
|
local function noisegrid_spawnplayer(player)
|
||||||
|
local xsp
|
||||||
|
local ysp
|
||||||
|
local zsp
|
||||||
|
local nobj_base = nil
|
||||||
|
|
||||||
|
for chunk = 1, 128 do
|
||||||
|
print ("[noisegrid] searching for spawn " .. chunk)
|
||||||
|
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||||
|
local z0 = 80 * math.random(-PSCA, PSCA) - 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 = 1}
|
||||||
|
local minposxz = {x = x0, y = z0}
|
||||||
|
|
||||||
|
nobj_base = nobj_base or minetest.get_perlin_map(np_base, chulens)
|
||||||
|
|
||||||
|
local nvals_base = nobj_base:get2dMap_flat(minposxz)
|
||||||
|
|
||||||
|
local nixz = 1
|
||||||
|
for z = z0, z1 do
|
||||||
|
for x = x0, x1 do
|
||||||
|
local ysurf
|
||||||
|
local n_base = nvals_base[nixz]
|
||||||
|
local n_absbase = math.abs(n_base)
|
||||||
|
if n_base > TFLAT then
|
||||||
|
ysurf = YFLAT + math.floor((n_base - TFLAT) * TERSCA)
|
||||||
|
elseif n_base < -TFLAT then
|
||||||
|
ysurf = YFLAT - math.floor((-TFLAT - n_base) * TERSCA)
|
||||||
|
else
|
||||||
|
ysurf = YFLAT
|
||||||
|
end
|
||||||
|
if ysurf >= 1 then
|
||||||
|
ysp = ysurf + 1
|
||||||
|
xsp = x
|
||||||
|
zsp = z
|
||||||
|
break
|
||||||
|
end
|
||||||
|
nixz = nixz + 1
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
print ("[noisegrid] spawn player (" .. xsp .. " " .. ysp .. " " .. zsp .. ")")
|
||||||
|
player:setpos({x = xsp, y = ysp, z = zsp})
|
||||||
|
else
|
||||||
|
print ("[noisegrid] no suitable spawn found")
|
||||||
|
player:setpos({x = 0, y = 2, z = 0})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
noisegrid_spawnplayer(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
noisegrid_spawnplayer(player)
|
||||||
|
return true
|
||||||
|
end)
|
||||||
|
@ -17,7 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
License of media (textures)
|
License of media (textures)
|
||||||
--------------------------------------
|
---------------------------
|
||||||
Copyright (C) 2014-2015 paramat
|
Copyright (C) 2014-2015 paramat
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
@ -58,7 +58,6 @@ minetest.register_node("noisegrid:slab", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
buildable_to = true,
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
@ -116,6 +115,7 @@ minetest.register_node("noisegrid:light", {
|
|||||||
tiles = {"noisegrid_light.png"},
|
tiles = {"noisegrid_light.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
|
is_ground_content = false,
|
||||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
})
|
})
|
||||||
@ -132,6 +132,7 @@ minetest.register_node("noisegrid:luxore", {
|
|||||||
description = "Lux Ore",
|
description = "Lux Ore",
|
||||||
tiles = {"noisegrid_luxore.png"},
|
tiles = {"noisegrid_luxore.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
@ -147,4 +148,3 @@ minetest.register_craft({
|
|||||||
{"default:glass", "default:glass", "default:glass"},
|
{"default:glass", "default:glass", "default:glass"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user