WoW:Chronos (AddOn)
Chronos provides functionality that makes tracking timed tasks and distributed tasks easier. This addon is a function library. This means that it doesn't have any UI on it's own, but rather provides functionality for other addons. If you are an addon user and not an addon developer all you need to do is to leave this addon turned on if you have any other addons that depend on it.
Download[edit]
The most current version is available at wowinterface.com.
Example[edit]
Chronos.schedule(10, foo, "a");
Will call foo("a") in 10 seconds.
Note: Do not include () after your function name, which coders tend do to often like Chronos.schedule(10, foo(), "a"); this causes your function to be called immediately and Chronos will try to "call" the return value of your function after the specified interval (which is not neccesarily bad if your function returns a function...)
Chronos.startTimer("SomeID"); foo() delta = Chronos.endTimer("SomeID");
Will return the amount of time needed to run foo.
Chronos Documentation[edit]
Chronos Functions[edit]
- afterInit - runs a function after the game starts.
- schedule - schedules a function to be called after a delay
- scheduleByName - schedules a function to be called after a delay by name
- scheduleRepeating - schedules a function to be called repetedly every X seconds
- unscheduleByName - unschedules a function created by scheduleByName or scheduleRepeating
- isScheduledByName - determines if a function is scheduled already by scheduleByName or scheduleRepeating
- startTimer - starts a timer
- getTimer - returns the amount of time since the timer was started
- endTimer - ends a timer and returns the amount of time since the timer was started
Chronos Examples[edit]
Chronos.scheduleByName("TEST", 120, bar, "a"); Chronos.scheduleByName("TEST", 12, bar, "a");
Will call bar("a") after 12 seconds (overwriting the first timer).
(performTask was removed in v2.01 of Chronos)
Chronos.performTask( { begin = function() Sea.io.print("Hello!"); setglobal("a", 0); end; step = function() Sea.io.print(getglobal("a")); setglobal("a", getglobal("a")+1); end; end = function() Sea.io.print("Bye!"); end; isDone = function() return ( getglobal("a") > 50 ) end; } );
Will print
Hello! 1 2 ... 50 Bye!
But it will do it over the course of 50 frames. Properly used, this can prevent "choppiness" and make a cpu intensive mod much much better.
Chronos was developed by AlexanderYoshi , with help from Thott.
If you wish to contribute improvements, please use the discussion forums.