Fix spawnplayer function

master
paramat 2014-05-22 23:15:33 +01:00
parent 4420f09ae2
commit ab8e29edbb
2 changed files with 15 additions and 10 deletions

View File

@ -107,9 +107,12 @@ end)
-- Spawn player
function spawnplayer(player)
-- Parameters
local SCAT = 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
@ -121,10 +124,10 @@ function spawnplayer(player)
octaves = 6,
persist = 0.6
}
for chunk = 1, 64 do
for chunk = 1, 128 do
print ("[noisegrid] searching for spawn "..chunk)
local x0 = 80 * math.random(-4, 4) - 32
local z0 = 80 * math.random(-4, 4) - 32
local x0 = 80 * math.random(-SCAT, SCAT) - 32
local z0 = 80 * math.random(-SCAT, SCAT) - 32
local y0 = -32
local x1 = x0 + 79
local z1 = z0 + 79
@ -165,8 +168,13 @@ function spawnplayer(player)
break
end
end
print ("[noisegrid] spawn player ("..xsp.." "..ysp.." "..zsp..")")
player:setpos({x=xsp, y=ysp, z=zsp})
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)

View File

@ -3,10 +3,7 @@
-- Depends default
-- License: code WTFPL
-- path node
-- grass areas with varing density
-- stability system
-- spawnplayer at surface
-- Fix spawnplayer: player scatter parameter, default 16 = 1280n, 128 tries
-- Parameters
@ -19,7 +16,7 @@ local TFIS = 0.02 -- Fissure threshold, controls width
local ORECHA = 1 / 4 ^ 3 -- Ore chance per stone node
local APPCHA = 1 / 4 ^ 2 -- Appletree maximum chance per grass node
local FLOCHA = 1 / 13 ^ 2 -- Flowers chance per grass node
local GRACHA = 1 / 4 ^ 2 -- Grasses maximum chance per grass node
local GRACHA = 1 / 5 ^ 2 -- Grasses maximum chance per grass node
-- 2D noise for base terrain