I have some sequences that I'd like to start, and the "easiest" way would be to trigger a script, do an effect, sleep for .5 seconds (or so), do another effect, and etcetera. But I don't see a sleep(), delay(), or wait() function in lua. Can this be done? When I trigger the following script, for example, I get two firebursts at random locations, but at the same time:
Code: Select all
function twoFirebursts()
spawn("fireburst", self.level, self.x + math.random(-1, 1), self.y + math.random(-1, 1), 0)
--sleep(.5) --I would like to insert a .5 second delay here...
spawn("fireburst", self.level, self.x + math.random(-1, 1), self.y + math.random(-1, 1), 0)
end
Or do I have to do something like this? Change the code to spawn one fireburst...
Code: Select all
function oneFireburst()
spawn("fireburst", self.level, self.x + math.random(-1, 1), self.y + math.random(-1, 1), 0)
timer_fireburst_1:deactivate()
end
...and then trigger for the script would be modified to activate the script and a timer that was deactivated and set to .5 seconds. The timer in turn activates the script again. This works fine for this example, but this is just an example and not what I really want. I've searched the forums for such a feature, but I can't find one. All help is greatly appreciated! Thank you,
-Lark