Fix crash with missing attacker position

This commit is contained in:
BlockMen 2014-01-14 15:37:23 +01:00
parent b8ffcb9afe
commit fd0d11df1c
1 changed files with 9 additions and 7 deletions

View File

@ -319,6 +319,7 @@ MUMMY_DEF.on_step = function(self, dtime)
if self.attacker ~= "" and minetest.setting_getbool("enable_damage") then
local s = self.object:getpos()
local p = self.attacker:getpos()
if (s ~= nil and p ~= nil) then
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist < 2 and self.attacking_timer > 0.6 then
@ -330,6 +331,7 @@ MUMMY_DEF.on_step = function(self, dtime)
end
end
end
end
end
minetest.register_entity("pyramids:mummy", MUMMY_DEF)