Updated: 10-16-08 10:20 PM
Updated:10-16-08 10:20 PM

Chronos  Popular! (More than 5000 hits)

Version: 2.12.30000
by: AnduinLothar [More]

Chronos manages time. You can schedule a function to be called in X seconds, with or without an id. You can request a timer, which tracks the elapsed duration since the timer was started.

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.

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...)

delta = Chronos.endTimer("SomeID");

Will return the amount of time needed to run foo.

Chronos Functions

  • 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
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)
begin = function()"Hello!"); setglobal("a", 0); end;
step = function()"a")); setglobal("a", getglobal("a")+1); end;
end = function()"Bye!"); end;
isDone = function() return ( getglobal("a") > 50 ) end;

Will print

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 initially developed by AlexanderYoshi, with help from Thott.
Redesigned by AnduinLothar.

If you wish to contribute improvements, please use the addon comments.

- Updated toc to 30000

- Updated toc to 20400
- Added Spanish localization

- Fixed table recycling so that it isn't nilling passed argument values (only does a shallow recycle on known safe tables)
- Fixed t.arg typo that was causing some events not to fire

- Updated for Lua 5.1
- Converted all a1-a20 args to ... usages since it now does not create a table.

- Embeddable/Standalone version, reverse compatible as always.
- Rearanged code to be more organized, no version change.

v2.0 (Embeddable)
- Embedable!
- Cleaned up OO code
- Removed completely unused threading (performTask) and global onupdate (everyFrame) - Backwards compatible with all other calls. If someone actually used those, let me know! I might make them optional if registered.
- Increased execution speed with less OnUpdate code
- Moved afterInit to after the chat channels have spammed their color changing.

Intermediate changes
- Updated toc to 11000

Rev: 2789
- REALLY fixed 'next' error. For future refrence it was incurred by removing the current key/value pair from a table while itterating over it with a for loop. Unfortunetly no one wrote this down before, so the sam problem someone else fixed was recreated on accident in an attempt to make more efficient. '''(CORRECT)'''

Rev: 2789
- Merged the repeating and byName lists for OnUpdate efficiency. (Note: this also means scheduleByName and scheduleRepeating can no longer have the same names)
- Added Chronos.flushByName(name, when) - Updates the ByName or Repeating event to flush at the time specified. If no time is specified flush will be immediate. If it is a Repeating event the timer will be reset.
- Added Chronos.debug(booleanEnable) for debugging. This also means that the normal OnUpdate function has been shortened and is now slimmer/quicker.
- unscheduleRepeating and isScheduledRepeating now mirror unscheduleByName and isScheduledByName for backwards compatibility.
- Fixed 'next' error that was cropping up in the for loops when niling before calling a local var. '''(INCORRECT)'''

Rev: 2782
- Fixed index number bug '''(INCORRECT)'''

Rev: 2781
- Fixed invalid key for 'next' bug. '''(INCORRECT)'''

Rev: 2778
- No longer requires Sea
- Updated TOC file loading method
- Made schedule calls a tad more efficient
- converted OnUpdate while loops into for loops for efficiency

Rev: 2777
- Added Chronos.scheduleRepeating(name, delay, function) which calls functions (without arguments) every X (delay) seconds. Useful for simulating OnUpdate for efficency (ex delay of .1 would call the function 10x/sec). Recall this function to update the time. (ex Chronos.scheduleRepeating(name, delay) )
- Added the Chronos.unscheduleRepeating(name)
- Added Chronos.IsScheduledRepeating(name)
- Updated TOC to 1800
Optional Files (0)

Post A Reply Comment Options
Unread 11-03-10, 12:09 AM  
Premium Member
Verissi's Avatar
AddOn Author - Click to view AddOns

Forum posts: 99
File comments: 29
Uploads: 2
I've fixed a copy locally and found the changes rather light. The getglobal/setglobal lines need to be fixed to use _G, and the OnUpdate and OnEvent functions need to be updated slightly. I can post a patch if needed. I'll PM AnduinLothar as well (tomorrow...need sleep!) and file a bug.

Update: I filed a bug here with a diff, for those interested in what needed fixing.
"I can calculate the motions of the heavenly bodies, but not the madness of people." - Sir Isaac Newton
"Half of twice as intimidating as Saurfang is still one whole Saurfang worth of intimidation." - Anticlaus, Gorefiend server
Last edited by Verissi : 11-03-10 at 05:34 PM.
Report comment to moderator  
Reply With Quote
Unread 10-31-10, 06:34 AM  
A Cyclonian
Fiercy's Avatar
AddOn Author - Click to view AddOns

Forum posts: 40
File comments: 142
Uploads: 7
Originally posted by Zensunim
Sadly, this mod no longer works in 4.0.1
There are countless ingredients that make up the human body and mind, like all the components that make up me as an individual with my own personality. Sure, I have a face and voice to distinguish myself from others, but my thoughts and memories are unique only to me, and I carry a sense of my own destiny. Each of those things are just a small part of it. I collect information to use in my own way. All of that blends to create a mixture that forms me and gives rise to my conscience.
Report comment to moderator  
Reply With Quote
Unread 10-13-10, 12:32 AM  
A Defias Bandit
AddOn Author - Click to view AddOns

Forum posts: 3
File comments: 104
Uploads: 1
Sadly, this mod no longer works in 4.0.1
Report comment to moderator  
Reply With Quote
Unread 10-16-08, 10:30 PM  
A Defias Bandit
AddOn Author - Click to view AddOns

Forum posts: 3
File comments: 309
Uploads: 1
Thank you for keeping Chronos updated.
Report comment to moderator  
Reply With Quote
Unread 12-18-06, 12:26 AM  
A Deviate Faerie Dragon

Forum posts: 14
File comments: 123
Uploads: 0
any news..

..about buffoptions?
Report comment to moderator  
Reply With Quote
Post A Reply

Category Jump: