1
0
Fork 0

Fix undefined global warning for variable distance in spawning code (#4348)

Fixes the warning about an undeclared global that occurs the first time a mob attempts to spawn.

Reviewed-on: VoxeLibre/VoxeLibre#4348
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
teknomunk 2024-05-31 09:54:59 +00:00 committed by the-real-herowl
parent f53bedc131
commit ecf12b85cc
1 changed files with 1 additions and 1 deletions

View File

@ -633,7 +633,7 @@ local function get_next_mob_spawn_pos(pos)
-- those further away from the player. -- those further away from the player.
local fx = (math_random(1,10000)-1) / 10000 local fx = (math_random(1,10000)-1) / 10000
local x = inverse_pwl(fx, SPAWN_DISTANCE_CDF_PWL) local x = inverse_pwl(fx, SPAWN_DISTANCE_CDF_PWL)
distance = x * (MOB_SPAWN_ZONE_OUTER - MOB_SPAWN_ZONE_INNER) + MOB_SPAWN_ZONE_INNER local distance = x * (MOB_SPAWN_ZONE_OUTER - MOB_SPAWN_ZONE_INNER) + MOB_SPAWN_ZONE_INNER
--print("Using spawn distance of "..tostring(distance).." fx="..tostring(fx)..",x="..tostring(x)) --print("Using spawn distance of "..tostring(distance).." fx="..tostring(fx)..",x="..tostring(x))
-- TODO Floor xoff and zoff and add 0.5 so it tries to spawn in the middle of the square. Less failed attempts. -- TODO Floor xoff and zoff and add 0.5 so it tries to spawn in the middle of the square. Less failed attempts.