nil check for self.attack

This commit is contained in:
tenplus1 2020-07-27 19:17:07 +01:00
parent cb465559a1
commit 565c0851eb
1 changed files with 3 additions and 2 deletions

View File

@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20200725", version = "20200727",
intllib = S, intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {} invis = minetest.global_exists("invisibility") and invisibility or {}
} }
@ -2257,7 +2257,7 @@ function mob_class:do_states(dtime)
-- get mob and enemy positions and distance between -- get mob and enemy positions and distance between
local s = self.object:get_pos() local s = self.object:get_pos()
local p = self.attack:get_pos() local p = self.attack and self.attack:get_pos()
local dist = p and get_distance(p, s) or 500 local dist = p and get_distance(p, s) or 500
-- stop attacking if player out of range or invisible -- stop attacking if player out of range or invisible
@ -3701,6 +3701,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
-- Do mobs spawn at all? -- Do mobs spawn at all?
if not mobs_spawn or not mobs.spawning_mobs[name] then if not mobs_spawn or not mobs.spawning_mobs[name] then
--print ("--- spawning not registered for " .. name)
return return
end end