Heretic
Resource contributor
- Messages
- 6,830
- Country

Don't want to clutter up the timer thread, so here's another one.
The easiest form to implement a timer, or something counting up or down, is something akin to this:
This looks clean and simple and the 0.055556 ensures that the variable is roughly incremented by 1 unit per second as the default update rate for gauges is 18 Hz or 18 times per second.
There is, however, a problem, namely that FSX will continue to run this script despite the sim being paused. The result can be undesired side effects, but there's a solution in form of a key event capture, an L: variable and a comparison.
Whenever the sim is paused with the "pause" function, the gauge will assign the current time to an L: var. This L: var is compared against the current simulation time. If they match, the timer will not be run and vice versa.
Might be old news to some, but those who didn't know this yet, now have yet another lean and clean possibility to implement a timer.
- Edit: Added simulation rate.
The easiest form to implement a timer, or something counting up or down, is something akin to this:
Code:
<Update>
<Script>
(L:Variable,enum) 0.055556
(P:Simulation Rate,number) *
+ (>L:Variable,enum)
</Script>
</Update>
This looks clean and simple and the 0.055556 ensures that the variable is roughly incremented by 1 unit per second as the default update rate for gauges is 18 Hz or 18 times per second.
There is, however, a problem, namely that FSX will continue to run this script despite the sim being paused. The result can be undesired side effects, but there's a solution in form of a key event capture, an L: variable and a comparison.
Code:
<Update>
<Script>
(P:ABSOLUTE TIME,seconds) (L:PAUSE,enum) !=
(A:IS SLEW ACTIVE,bool) !
and
if{ (L:Variable,enum) 0.055556
(P:Simulation Rate,number) *
+ (>L:Variable,enum) }
</Script>
</Update>
<KeyMap>
<Trigger>
<KeyEvent>PAUSE_TOGGLE</KeyEvent>
<Script>
(P:ABSOLUTE TIME,seconds) (>L:PAUSE,enum)
</Script>
</Trigger>
</KeyMap>
Whenever the sim is paused with the "pause" function, the gauge will assign the current time to an L: var. This L: var is compared against the current simulation time. If they match, the timer will not be run and vice versa.
Might be old news to some, but those who didn't know this yet, now have yet another lean and clean possibility to implement a timer.
- Edit: Added simulation rate.
Last edited:




