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([number
tick 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
number
optional, 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(function
callback to call, number
delay in ms, [string
callback 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
function
callback to call
2
number
delay in ms
3
string
optional, default value=nil
callback name
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 140
-
timer_manager:repeat_callback(function
callback to call, number
delay in ms, [string
callback 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
function
callback to call
2
number
delay in ms
3
string
optional, default value=nil
callback name
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 203
-
timer_manager:remove_callback(string
name 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_manager
to remove callbacks, however on thebattle_manager
it's more common to callbattle_manager:remove_process
instead (which also removes matchingWatches
).Parameters:
1
string
name name to remove
Returns:
boolean
any 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(string
function name, number
time 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:callback
instead.Parameters:
1
string
function name
2
number
time in ms
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 297
-
timer_manager:register_repeating_timer(string
function name, number
time 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_callback
instead.Parameters:
1
string
function name
2
number
time in ms
Returns:
nil
defined in ../working_data/script/_lib/lib_timer_manager.lua, line 316
-
timer_manager:unregister_timer(string
function name)
-
Cancels a timer registered with
timer_manager:register_singleshot_timer
ortimer_manager:register_repeating_timer
. As is the case with those functions, don't use this unless strictly necessary.Parameters:
1
string
function 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