LibRockTimer-1.0 API Documentation
From WowAce Wiki
(Redirected from LibRockTimer-1.0)
Contents |
[edit]
API Documentation
Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.
[edit]
:AddRepeatingTimer(uid , delay , callback , ...)
[edit]
Arguments
- uid
- string or number - a unique identifier, to allow for easy removal later. Optional, default: nil.
- delay
- number - the amount of seconds until the callback is fired. Must be either 0 or >= 0.05.
- callback
- string or function - the method name or function to call.
- ...
- tuple - a list of arguments to pass along.
[edit]
Notes
- Add a timer that will fire in the allotted time and repeatedly every so often after that point.
- To fire on every frame, specify a delay of 0.
- This will run every `delay` that you set. This keeps track of the original starting time and goes by that instead of running every `delay` after each run, which actually, due to the lack of infinite framerate, would cause it to run every `delay` + epsilon seconds. Without lag spikes, this will run 10 times in 10 seconds for a delay of 1, instead of possibly 9 or 8 times, never catching up.
- If a lag spike occurs where multiple seconds are lost, all waiting timers will be run, but will not play a game of "catch-up", i.e. if you have a delay of 1, you lose 10 seconds, instead of running the timer 10x in the next 10 frames, it will run the next frame, somewhere between 0-1 seconds later (depending on the length of the lag spike, it stays in tune with the original time), and then every second after that.
[edit]
Example
MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
[edit]
:AddTimer(uid , delay , callback , ...)
[edit]
Arguments
- uid
- string or number - a unique identifier, to allow for easy removal later. Optional, default: nil.
- delay
- number - the amount of seconds until the callback is fired. Must be either 0 or >= 0.05.
- callback
- string or function - the method name or function to call.
- ...
- tuple - a list of arguments to pass along.
[edit]
Notes
- Add a timer that will fire in the allotted time.
- To fire on the next frame, specify a delay of 0.
[edit]
Example
MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
[edit]
:HasTimer(uid)
[edit]
Arguments
- uid
- string or number - a unique identifier.
[edit]
Notes
- Remove a timer with the specified uid.
[edit]
Returns
boolean or number - false if the timer does not exist, otherwise the amount of time until the timer goes off.
[edit]
Example
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
local hasTimer = MyAddon:HasTimer("myUID")
[edit]
:RemoveAllTimers()
[edit]
Notes
- Remove all timers created by this object.
[edit]
Example
MyAddon:RemoveAllTimers()
[edit]
:RemoveTimer(uid)
[edit]
Arguments
- uid
- string or number - a unique identifier.
[edit]
Notes
- Remove a timer with the specified uid.
[edit]
Returns
boolean - whether the timer was actually removed.
[edit]
Example
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
MyAddon:RemoveTimer("myUID")

