mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-26 00:50:21 +01:00
nil check for get_distance
This commit is contained in:
parent
f033cd401c
commit
4814f53885
2
api.lua
2
api.lua
@ -195,7 +195,7 @@ end
|
|||||||
|
|
||||||
-- calculate distance
|
-- calculate distance
|
||||||
local get_distance = function(a, b)
|
local get_distance = function(a, b)
|
||||||
|
if not a or not b then return 50 end -- nil check
|
||||||
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
|
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
|
||||||
|
|
||||||
return square(x * x + y * y + z * z)
|
return square(x * x + y * y + z * z)
|
||||||
|
Loading…
Reference in New Issue
Block a user