summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2015-03-26 07:29:34 +0100
committerJeija <norrepli@gmail.com>2015-03-26 07:29:34 +0100
commitb6ae419b009a2b547ec3ec40f76e4108194a2335 (patch)
tree5aad085bcdf83b9ee56e9bcdff71523300ae7634
parenta6d0a523ba896762ac8b0d327863e523ab86dc47 (diff)
downloadmesecons-b6ae419b009a2b547ec3ec40f76e4108194a2335.tar
mesecons-b6ae419b009a2b547ec3ec40f76e4108194a2335.tar.gz
mesecons-b6ae419b009a2b547ec3ec40f76e4108194a2335.tar.bz2
mesecons-b6ae419b009a2b547ec3ec40f76e4108194a2335.tar.xz
mesecons-b6ae419b009a2b547ec3ec40f76e4108194a2335.zip
Return if invalid parameters are given to node_detector_scan (e.g. unloaded area), should fix #228
-rw-r--r--mesecons_detector/init.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua
index 1a8595d..e589676 100644
--- a/mesecons_detector/init.lua
+++ b/mesecons_detector/init.lua
@@ -135,8 +135,12 @@ end
-- returns true if player was found, false if not
local node_detector_scan = function (pos)
- local node = minetest.get_node(pos)
- local frontpos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
+ if not pos then return end
+ local node = minetest.get_node_or_nil(pos)
+ if not node then return end
+ local scandir = minetest.facedir_to_dir(node.param2)
+ if not scandir then return end
+ local frontpos = vector.subtract(pos, scandir)
local frontnode = minetest.get_node(frontpos)
local meta = minetest.get_meta(pos)
return (frontnode.name == meta:get_string("scanname")) or