Skip to content
Download

Wait and repeat

objects/Bomb.lua
function onSpawn(self)
self:afterSeconds(3, function() self:destroy() end)
self.pisca = self:every(30, function() self.visible = not self.visible end)
end
  • after and every count in steps (60 per second); afterSeconds, in seconds.
  • Each function returns an id; cancel(id) cancels it.
  • Timers end when the instance is destroyed.

For an ordered series of events (enemy waves, a cutscene), self:run avoids counters in onUpdate. In C++, chain after calls.

self:run(function()
wait(2)
spawn("Enemy", 160, 0, "Instancias")
waitUntil(function() return not any("Enemy") end)
goTo("Vitoria")
end)

Reference: Timers.