Timer Manager
The timer manager object provides library support for calling functions with a time offset i.e. waiting a period before calling a function. It is loaded in battle and the frontend.
It is rare for battle scripts to need to talk directly to the timer manager as the battle manager automatically creates a timer manager and provides a pass-through interface for the most-commonly-used timer manager functionality. See the Timer Manager section of the battle_manager documentation for more information.
Direct access to the timer manager might be more useful for frontend scripts, but they are rarer in themselves.
| Loaded in Battle |
|
| Loaded in Frontend |
|
-
timer_manager:new([numbertick time]) -
Creates a timer_manager object. It is unnecessary for battle scripts to call this as one is created automatically by the battle manager, and stored internally.
Parameters:
1
numberoptional, default value=100
Model tick time in ms. Defaults to 100ms.
Returns:
timer_manager
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 60
-
timer_manager:callback(functioncallback to call, numberdelay in ms, [stringcallback name]) -
Instructs the timer manager to call a supplied function after a supplied delay. A string name for the callback may also be supplied with which the callback may be later cancelled using
timer_manager:remove_callback(note that in battle it's much more common to usebattle_manager:remove_process).Parameters:
1
functioncallback to call
2
numberdelay in ms
3
stringoptional, default value=nil
callback name
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 140
-
timer_manager:repeat_callback(functioncallback to call, numberdelay in ms, [stringcallback name]) -
Instructs the timer manager to call a supplied function after a supplied delay, and then repeatedly after the same delay. A string name for the callback may also be supplied with which the callback may be later cancelled using
timer_manager:remove_callback(note that in battle it's much more common to usebattle_manager:remove_process).Parameters:
1
functioncallback to call
2
numberdelay in ms
3
stringoptional, default value=nil
callback name
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 203
-
timer_manager:remove_callback(stringname name to remove) -
Instructs the timer manager to remove any active callback with the supplied name. This is the main method at the level of
timer_managerto remove callbacks, however on thebattle_managerit's more common to callbattle_manager:remove_processinstead (which also removes matchingWatches).Parameters:
1
stringname name to remove
Returns:
booleanany callbacks removed
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 214
Do not use the functions provided here! Do not remove this either, however, as the callback system is built on top of it.
-
timer_manager:register_singleshot_timer(stringfunction name, numbertime in ms) -
Registers a handler name (function name) to be called and a period in ms after which to call it. Do not use this unless strictly necessary - it's only provided for legacy support. Use
timer_manager:callbackinstead.Parameters:
1
stringfunction name
2
numbertime in ms
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 297
-
timer_manager:register_repeating_timer(stringfunction name, numbertime in ms) -
Registers a handler name (function name) to be called and a period in ms after which to repeatedly call it. Do not use this unless strictly necessary - it's only provided for legacy support. Use
timer_manager:repeat_callbackinstead.Parameters:
1
stringfunction name
2
numbertime in ms
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 316
-
timer_manager:unregister_timer(stringfunction name) -
Cancels a timer registered with
timer_manager:register_singleshot_timerortimer_manager:register_repeating_timer. As is the case with those functions, don't use this unless strictly necessary.Parameters:
1
stringfunction name
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 328
-
timer_manager:print_timer_list() -
Writes the current timer list to the console, for debugging purposes.
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 366
-
timer_manager:print_callback_list() -
Writes the current callback list to the console, for debugging purposes.
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 392
-
timer_manager:clear_callback_list() -
Clears all callbacks. This shouldn't really be used for client scripts, if you need to do this you're probably doing something wrong.
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 425