Fix crash caused by lack of luaentity nil check and minetest 5.6
This commit is contained in:
parent
c8ecf77255
commit
d4d89c5cc4
15
mummy.lua
15
mummy.lua
@ -284,7 +284,9 @@ MUMMY_DEF.on_step = function(self, dtime)
|
||||
if self.state == 1 then
|
||||
self.yawwer = true
|
||||
self.attacker = ""
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 4)) do
|
||||
local pos_obj = self.object:get_pos()
|
||||
if pos_obj then
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos_obj, 4)) do
|
||||
if object:is_player() then
|
||||
self.yawwer = false
|
||||
local NPC = self.object:get_pos()
|
||||
@ -299,6 +301,7 @@ MUMMY_DEF.on_step = function(self, dtime)
|
||||
self.attacker = object
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.attacker == "" and self.turn_timer > math.random(1,4) then
|
||||
self.yaw = 360 * math.random()
|
||||
@ -306,7 +309,8 @@ MUMMY_DEF.on_step = function(self, dtime)
|
||||
self.turn_timer = 0
|
||||
self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
|
||||
end
|
||||
self.object:set_velocity({x=0,y=self.object:get_velocity().y,z=0})
|
||||
local old_vel = self.object:get_velocity()
|
||||
self.object:set_velocity({x=0,y=old_vel and old_vel.y or 0,z=0})
|
||||
if self.npc_anim ~= ANIM_STAND then
|
||||
self.anim = get_animations()
|
||||
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
|
||||
@ -321,7 +325,12 @@ MUMMY_DEF.on_step = function(self, dtime)
|
||||
if self.state == 2 then
|
||||
|
||||
if self.direction ~= nil then
|
||||
self.object:set_velocity({x=self.direction.x*mummy_chillaxin_speed,y=self.object:get_velocity().y,z=self.direction.z*mummy_chillaxin_speed})
|
||||
local old_vel = self.object:get_velocity()
|
||||
self.object:set_velocity({
|
||||
x=self.direction.x*mummy_chillaxin_speed,
|
||||
y=old_vel and old_vel.y or 0,
|
||||
z=self.direction.z*mummy_chillaxin_speed,
|
||||
})
|
||||
end
|
||||
if self.turn_timer > math.random(1,4) and not self.attacker then
|
||||
self.yaw = 360 * math.random()
|
||||
|
Loading…
Reference in New Issue
Block a user