mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-24 17:50:21 +01:00
add nil check to line_of_sight
This commit is contained in:
parent
77c19da8d4
commit
42473cbc23
3
api.lua
3
api.lua
@ -239,6 +239,8 @@ end
|
|||||||
-- check line of sight (by BrunoMine, tweaked by Astrobe)
|
-- check line of sight (by BrunoMine, tweaked by Astrobe)
|
||||||
local line_of_sight = function(self, pos1, pos2, stepsize)
|
local line_of_sight = function(self, pos1, pos2, stepsize)
|
||||||
|
|
||||||
|
if not pos1 or not pos2 then return end
|
||||||
|
|
||||||
stepsize = stepsize or 1
|
stepsize = stepsize or 1
|
||||||
|
|
||||||
local stepv = vector.multiply(vector.direction(pos1, pos2), stepsize)
|
local stepv = vector.multiply(vector.direction(pos1, pos2), stepsize)
|
||||||
@ -283,6 +285,7 @@ end
|
|||||||
|
|
||||||
-- global function
|
-- global function
|
||||||
function mobs:line_of_sight(self, pos1, pos2, stepsize)
|
function mobs:line_of_sight(self, pos1, pos2, stepsize)
|
||||||
|
|
||||||
return line_of_sight(self, pos1, pos2, stepsize)
|
return line_of_sight(self, pos1, pos2, stepsize)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user