better checks for nil on find method and player object

* really closes https://notabug.org/TenPlus1/mobs_redo/issues/114 again
* really closes #107
* nil checks
* improve the previous commit f78202cf8e1d4ba59bbe57cf774d2ba26b69ffc3
This commit is contained in:
Герхард PICCORO Lenz McKAY 2022-06-14 13:05:05 -04:00
parent f8db9f0f39
commit 3b03af0ba1

20
api.lua
View File

@ -272,18 +272,18 @@ local check_for = function(look_for, look_inside)
if not str then goto continue end
if str == look_for then
return true
end
if str and str:find("group:") then
if str then
if str:find("group:") then
local group = str:split(":")[2] or ""
if minetest.get_item_group(look_for, group) ~= 0 then
return true
end
end
end
if str == look_for then
return true
end
::continue::
end
@ -2120,15 +2120,15 @@ function mob_class:follow_flop()
for n = 1, #players do
if players[n] and get_distance(players[n]:get_pos(), s) < self.view_range
if players[n] then
if get_distance(players[n]:get_pos(), s) < self.view_range
and not is_invisible(self, players[n]:get_player_name()) then
self.following = players[n]
break
end
end
end
end
if self.type == "npc"
and self.order == "follow"