mwseTimerController⚓︎
A Timer Controller is a class used to sort and trigger callbacks based on an arbitrary timekeeping mechanic. By default there are three Timer Controllers for each type of timers: timer.simulate
, timer.game
or timer.real
.
Properties⚓︎
clock
⚓︎
The current clock time for this timer controller. Timer Controller, responsible for timer.game
type of timers, has clock equal to the game's simuation timestamp. Timer Controllers, responsible for timer.real
, and timer.simulate
, types of timers have their initial clock set to 0
on a new game, and their clock's progressions is equal to deltaTime
. Timer Controller's, responsible for timer.simulate
timers, clock only advances when the menu mode is off.
Returns:
result
(number)
Methods⚓︎
create
⚓︎
Creates a timer for the given Timer Controller.
Tip
It's recommended to study the Object Lifetimes guide. It describes how to safely use tes3reference objects inside timer callbacks.
local timer = myObject:create({ duration = ..., callback = ..., iterations = ..., persist = ..., data = ... })
Parameters:
params
(table)duration
(number): Duration of the timer. The method of time passing depends on the timer type.callback
(fun(e: mwseTimerCallbackData), string): The callback function that will execute when the timer expires. If starting a registered timer, this needs to be thename
string passed totimer.register
.iterations
(integer): Default:1
. The number of iterations to run. Use-1
for infinite looping.persist
(boolean): Default:true
. Registering a timer with persist flag set totrue
will serialize the callback string in the save to persist between sessions. Only a registered timer will persist between sessions. Seetimer.register()
.data
(table, nil): Default:nil
. Data to be attached to the timer. If this is a persistent timer, the data must be json-serializable, matching the same limitations as data stored on references.
Returns:
timer
(mwseTimer)
Functions⚓︎
new
⚓︎
Creates a new Timer Controller. Its initial clock is zero, unless a start time is provided.
local result = mwseTimerController.new(startTime)
Parameters:
startTime
(number): Optional.
Returns:
result
(mwseTimerController)