Initially the script is very simple:
the herderondie.onDieOne function runs when the herder die:
Code: Select all
cloneObject{
name = "herder_dying",
baseObject = "herder",
onDie = function(self)
return herderondie.onDieOne(self)
end,
}herderondie script:
Code: Select all
function onDieOne(self)
spawn("herder",self.level,self.x,self.y,self.facing)
endif I simply put a timer in the editor, the problem is with the "self" in the function, because the herder spawn where the timer is placed in the editor. So not possible.
So my idea was to spawn a timer where the first herder dies:
Code: Select all
herder_ondieone_sequence = 0
function onDieOne(self)
if herder_ondieone_sequence == 0 then
t = spawn("timer", self.level, self.x,self.y,self.facing, "timer_herder_ondie_one"..self.id)
t:setTimerInterval(0.25)
t:addConnector("activate", "herderondie", "onDieOne")
t:activate()
herder_ondieone_sequence = 1
elseif herder_ondieone_sequence == 1 then
spawn("herder",self.level,self.x,self.y,self.facing)
herder_ondieone_sequence = 0
t:deactivate()
t:destroy()
end
end