Download
(931 b)
Download
Updated: 05/02/14 03:05 PM
Compatibility:
Live (1.0)
Updated:05/02/14 03:05 PM
Created:05/02/14 03:05 PM
Monthly downloads:9
Total downloads:1,421
Favorites:1
MD5:
LD Timer Library
Version: 0.3
by: lintydruid [More]
A small timer library, supporting the management of one off, limited number of times and repeating timers. It has a resolution of 0.5 seconds (500ms) and used Zenimax's in built timer callback at it's core.


How to use it:

- Add it to you includes (at the top)

To add a simple timer

ld_timer.add("<timer name>", <how long to wait in ms>, <callback funciton>, <number of times to run>)

Code

ld_timer.add("my timer",1000,myFunction,3) -- call myFunction 3 times (once every second)

function myFunction(timerName)
d("timer: "..timerName)
end

To add a simple timer that returns data

ld_timer.addWithData("<timer name>", <how long to wait in ms>, <callback funciton>, <number of times to run>, <data>)

Code

ld_timer.add("my timer",2000,myFunction,0,{a=1,b=2,c=3}) -- call myFunction indefinitely (once every 2 seconds)

function myFunction(timerName, data)
d("timer: "..timerName.." :: "..data.a.."+"..data.b.."="..data.c)
end

replacing/overwriting a timer

Just issue an "add" or "addWithData" command with a matching <timer name>.

Checking if a timer exits

bool=ld_timer.exists("<timer name>")
There have been no comments posted to this file.
Be the first to add one.



Category Jump: