summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2018-08-08 11:23:40 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2018-08-08 11:23:40 +0100
commit42473cbc233f44dd73d28d5481b2c3862ac5e7bc (patch)
tree8a4c1cc0dc28016ff829adeb4dfe15e5055a2970
parent77c19da8d42521da8878e76045b8e45d91059e8f (diff)
add nil check to line_of_sight
-rw-r--r--api.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/api.lua b/api.lua
index 5f9a674..b5c8375 100644
--- a/api.lua
+++ b/api.lua
@@ -239,6 +239,8 @@ end
-- check line of sight (by BrunoMine, tweaked by Astrobe)
local line_of_sight = function(self, pos1, pos2, stepsize)
+ if not pos1 or not pos2 then return end
+
stepsize = stepsize or 1
local stepv = vector.multiply(vector.direction(pos1, pos2), stepsize)
@@ -283,6 +285,7 @@ end
-- global function
function mobs:line_of_sight(self, pos1, pos2, stepsize)
+
return line_of_sight(self, pos1, pos2, stepsize)
end