-
Notifications
You must be signed in to change notification settings - Fork 1
Timer Class create
DizzasTeR edited this page Feb 21, 2021
·
4 revisions
Creates a timer
Timer Timer.create(function callback, int interval, int repeat [, ...optionalParameters])
- function callback — A handler function to be called
- int interval — Timer interval in miliseconds (Minimum interval allowed is 50ms)
- int repeat — How many times should the timer repeat or -1 to repeat indefinitely
Instance - Timer instance/object if the timer was created successfully, nil if something went wrong.
When a timer callback/handler is executed, a hidden thisTimer variable is passed which references the current Timer instance being executed. This can be used to neatly deal with timers which aren't stored in a variable. Check Timer.destroy page example to see how its used.
Timer.create(function(myNum, myMsg)
Logger.info("["..myNum.."] -> "..myMsg)
end, 1000, 1, 100, "My Message")
Timer.create(function(data)
iprint(data)
end, 1000, 1, {100, "My other message", secret = "value"})