Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- An example for using Timer class to chain functions together
- -- (letting you insert delay between parts)
- -- Little bit simplified for verbosity
- -- First function to fire
- function SetupPartOne()
- print('Do the first thing here')
- -- Next function after 5 seconds
- CreateOneshotTimer('SetupPartTwo', 5)
- end
- -- Second function to fire
- function SetupPartTwo()
- print('Next thing')
- -- Next function after 12 seconds
- CreateOneshotTimer('SetupPartThree', 12)
- end
- -- Last function to fire
- function SetupPartThree()
- print('And so on, you get the idea')
- end
- -- Helper function for creating timers
- function CreateOneshotTimer(fcnName, delay)
- Timer.create({
- identifier = tostring({}), -- unique name
- function_name = fcnName, -- what it triggers
- function_owner = self,
- delay = delay, -- delay in seconds
- repetitions = 1, -- oneshot
- })
- end
- -- We'll be starting setup on load
- function onLoad()
- -- Start the first one whenever to fire off the chain
- SetupPartOne()
- end
Add Comment
Please, Sign In to add comment