From 232865e09beef2521cbb738fddbfed112adabd35 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Mon, 8 Jan 2018 01:49:54 -0500 Subject: [PATCH] add check and log warning for tmp_mob_name nil value --- spawners_mobs/api.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/spawners_mobs/api.lua b/spawners_mobs/api.lua index 1947022..fcf1649 100644 --- a/spawners_mobs/api.lua +++ b/spawners_mobs/api.lua @@ -320,14 +320,18 @@ function spawners_mobs.on_timer(pos, elapsed) object:get_luaentity().name ~= "__builtin:item" then local tmp_mob_name = string.split(object:get_luaentity().name, ":")[2] - -- sheeps have colors in names - if string.find(tmp_mob_name, "sheep") and string.find(mob_name, "sheep") and not string.find(tmp_mob_name, "dummy") then - -- print("found entity: "..tmp_mob_name) - entities_near = entities_near + 1 - - elseif tmp_mob_name == mob_name then - -- print("found entity: "..tmp_mob_name) - entities_near = entities_near + 1 + if tmp_mob_name ~= nil then + -- sheeps have colors in names + if string.find(tmp_mob_name, "sheep") and string.find(mob_name, "sheep") and not string.find(tmp_mob_name, "dummy") then + -- print("found entity: "..tmp_mob_name) + entities_near = entities_near + 1 + + elseif tmp_mob_name == mob_name then + -- print("found entity: "..tmp_mob_name) + entities_near = entities_near + 1 + end + else + minetest.log("warning", "[spawners_mobs] tmp_mob_name was nil, luaentity name was: "..object:get_luaentity().name) end end