From ecf12b85cc7b182e6ecd12abbd69de4b9f2040b5 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Fri, 31 May 2024 09:54:59 +0000 Subject: [PATCH] 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: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4348 Reviewed-by: the-real-herowl Co-authored-by: teknomunk Co-committed-by: teknomunk --- mods/ENTITIES/mcl_mobs/spawning.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 8a8a42281..c0e68e55b 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -633,7 +633,7 @@ local function get_next_mob_spawn_pos(pos) -- those further away from the player. local fx = (math_random(1,10000)-1) / 10000 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)) -- TODO Floor xoff and zoff and add 0.5 so it tries to spawn in the middle of the square. Less failed attempts.