LibRockTimer-1.0 API Documentation

From WowAce Wiki
Jump to: navigation, search

API Documentation

Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.

:AddRepeatingTimer(uid , delay , callback , ...)

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.

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.

Example

MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")

:AddTimer(uid , delay , callback , ...)

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.

Notes

  • Add a timer that will fire in the allotted time.
  • To fire on the next frame, specify a delay of 0.

Example

MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")

:HasTimer(uid)

Arguments

uid
string or number - a unique identifier.

Notes

  • Remove a timer with the specified uid.

Returns

boolean or number - false if the timer does not exist, otherwise the amount of time until the timer goes off.

Example

MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
local hasTimer = MyAddon:HasTimer("myUID")

:RemoveAllTimers()

Notes

  • Remove all timers created by this object.

Example

MyAddon:RemoveAllTimers()

:RemoveTimer(uid)

Arguments

uid
string or number - a unique identifier.

Notes

  • Remove a timer with the specified uid.

Returns

boolean - whether the timer was actually removed.

Example

MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
MyAddon:RemoveTimer("myUID")