1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-06-28 14:36:03 +02:00

replace :distance with get_distance() function

This commit is contained in:
tenplus1
2024-03-03 17:09:30 +00:00
parent 17dafff8ef
commit 87d13c857f
2 changed files with 16 additions and 6 deletions

View File

@ -11,6 +11,16 @@ local function is_player(player)
end
local get_distance = function(a, b)
if not a or not b then return 50 end -- nil check and default distance
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
return square(x * x + y * y + z * z)
end
-- mob spawner
local spawner_default = "mobs_animal:pumba 10 15 0 0 0"
@ -161,7 +171,7 @@ minetest.register_abm({
player = players[i]
if player:get_pos():distance(pos) <= pla then
if get_distance(player:get_pos(), pos) <= pla then
in_range = true