From b6ae419b009a2b547ec3ec40f76e4108194a2335 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 26 Mar 2015 07:29:34 +0100 Subject: Return if invalid parameters are given to node_detector_scan (e.g. unloaded area), should fix #228 --- mesecons_detector/init.lua | 8 ++++++-- 1 file 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 -- cgit v1.2.3