Timers⚓︎
Timers are a way to keep track with the passage of time. They are volatile, meaning that they do not persist between saved games.
Creating a Basic Timer⚓︎
To create a timer, pass a table of options to timer.start()
.
1 2 3 4 5 6 7 |
|
In the above example, we create a message box after 30 seconds.
Repeating a Timer⚓︎
Timers can repeat, based on an iterations parameter. This can be used to define a timer that will trigger multiple times.
1 2 3 4 5 6 7 |
|
Additionally, a value of -1
will create a timer that will repeat forever.
Controlling Timer State⚓︎
A timer's state (read through the .state
property), can be timer.active
, timer.paused
, or timer.expired
. An active timer is running normally. A paused timer doesn't run, but can be resumed to pick back up where it left off. An expired timer has finished running (and has no more iterations).
A timer can be told to pause, resume, reset, or cancel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Creating Different Types of Timers⚓︎
Three different types of timers are available, though an advanced user can create their own types of timers and manage their clock cycles. The default types are:
- Real, defined by
timer.real
. Real timers operate primarily on real time, incrementing seconds whenever the game window is active. - Simulate, defined by
timer.simulate
. Simulate timers operate much like real timers, incrementing seconds but only when the game is simulating (i.e. not in menu mode). This is the default type of timer. - Game, defined by
timer.game
. Game timers operate by game hour, matching game time.
1 2 3 4 5 6 7 8 |
|
Note
After reading the Timers guide, it's recommended to proceed to the Object Lifetimes guide. It describes how to safely use tes3reference objects inside timer callbacks.