From ab8e29edbb788e4cd48d5109dc0e59b55ff208dc Mon Sep 17 00:00:00 2001 From: paramat Date: Thu, 22 May 2014 23:15:33 +0100 Subject: [PATCH] Fix spawnplayer function --- functions.lua | 18 +++++++++++++----- init.lua | 7 ++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/functions.lua b/functions.lua index 670d4a4..89ba5d8 100644 --- a/functions.lua +++ b/functions.lua @@ -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) diff --git a/init.lua b/init.lua index 8fa049b..146b740 100644 --- a/init.lua +++ b/init.lua @@ -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