Fix crash

master
BlockMen 2014-03-13 21:29:55 +01:00
parent 11ed82040c
commit f570ca25b5
1 changed files with 3 additions and 1 deletions

View File

@ -160,6 +160,7 @@ end
SHEEP_DEF.on_step = function(self, dtime)
if self.dead then return end
if self.lifetime == nil then self.lifetime = 0 end
self.timer = self.timer + 0.01
self.lifetime = self.lifetime + 0.01
self.turn_timer = self.turn_timer + 0.01
@ -233,7 +234,8 @@ SHEEP_DEF.on_step = function(self, dtime)
end
-- play random sound
if self.sound_timer > self.timer + math.random(5,self.lifetime/2) then
local num = tonumber(self.lifetime/2) or 35
if self.sound_timer > self.timer + math.random(5, num) then
minetest.sound_play(s_sound_normal, {pos = current_pos, max_hear_distance = 10, gain = 0.7})
self.sound_timer = 0
end