Timer tidy
This commit is contained in:
parent
c3bf84b070
commit
106803d6a1
14
api.lua
14
api.lua
@ -431,7 +431,7 @@ local function breed(self)
|
|||||||
local ents = minetest.get_objects_inside_radius(pos, 3)
|
local ents = minetest.get_objects_inside_radius(pos, 3)
|
||||||
local num = 0
|
local num = 0
|
||||||
local ent = nil
|
local ent = nil
|
||||||
for i,obj in ipairs(ents) do
|
for i, obj in ipairs(ents) do
|
||||||
ent = obj:get_luaentity()
|
ent = obj:get_luaentity()
|
||||||
|
|
||||||
-- check for same animal with different colour
|
-- check for same animal with different colour
|
||||||
@ -463,6 +463,7 @@ local function breed(self)
|
|||||||
if num > 1 then
|
if num > 1 then
|
||||||
self.hornytimer = 41
|
self.hornytimer = 41
|
||||||
ent.hornytimer = 41
|
ent.hornytimer = 41
|
||||||
|
-- spawn baby
|
||||||
minetest.after(7, function(dtime)
|
minetest.after(7, function(dtime)
|
||||||
local mob = minetest.add_entity(pos, self.name)
|
local mob = minetest.add_entity(pos, self.name)
|
||||||
local ent2 = mob:get_luaentity()
|
local ent2 = mob:get_luaentity()
|
||||||
@ -613,10 +614,10 @@ minetest.register_entity(name, {
|
|||||||
|
|
||||||
-- when lifetimer expires remove mob (except npc and tamed)
|
-- when lifetimer expires remove mob (except npc and tamed)
|
||||||
if self.type ~= "npc"
|
if self.type ~= "npc"
|
||||||
and not self.tamed then
|
and not self.tamed
|
||||||
|
and self.state ~= "attack" then
|
||||||
self.lifetimer = self.lifetimer - dtime
|
self.lifetimer = self.lifetimer - dtime
|
||||||
if self.lifetimer <= 0
|
if self.lifetimer <= 0 then
|
||||||
and self.state ~= "attack" then
|
|
||||||
minetest.log("action",
|
minetest.log("action",
|
||||||
"lifetimer expired, removed " .. self.name)
|
"lifetimer expired, removed " .. self.name)
|
||||||
effect(pos, 15, "tnt_smoke.png")
|
effect(pos, 15, "tnt_smoke.png")
|
||||||
@ -691,6 +692,10 @@ minetest.register_entity(name, {
|
|||||||
end
|
end
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
end
|
end
|
||||||
|
-- never go over 100
|
||||||
|
if self.timer > 100 then
|
||||||
|
self.timer = 1
|
||||||
|
end
|
||||||
|
|
||||||
-- mob plays random sound at times
|
-- mob plays random sound at times
|
||||||
if self.sounds.random
|
if self.sounds.random
|
||||||
@ -712,6 +717,7 @@ minetest.register_entity(name, {
|
|||||||
self.do_custom(self)
|
self.do_custom(self)
|
||||||
end
|
end
|
||||||
elseif self.state ~= "attack" then
|
elseif self.state ~= "attack" then
|
||||||
|
self.env_damage_timer = 0
|
||||||
do_env_damage(self)
|
do_env_damage(self)
|
||||||
-- custom function
|
-- custom function
|
||||||
if self.do_custom then
|
if self.do_custom then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user