The Timer
object represents a one-shot or repeating timer. It can be scheduled for a specific amount of time, and will call a provided function after that interval. Optionally, the timer can be configured as a recurring timer.
Timer
objects can be canceled to prevent any further callbacks.
Timers fire during X-Plane's flight loop callbacks, ocurring before physics.
Timer.delay
is the current delay or interval of this timer. When this value is changed, the new interval is measured from when the timer last fired, or when it was created.Timer.func
is the callback function of this timer.Timer.cancel()
prevents this timer from firing again.Timer(func)
creates a timer; it needs to be scheduled before it will fire.Timer.scheduleOnce(delay)
schedules a one-shot timer.Timer.scheduleRepeat(delay)
schedules a repeating timer.None.
// A one shot timer:
> timer = new Timer"Fired!";
undefined
> 0 1;
undefined
Fired!
// A repeating timer:
> timer2 = new Timer"Repeat fire!";
undefined
> 0 1;
undefined
Repeat fire!
Repeat fire!
Repeat fire!
> timer2.delay
100
>
undefined
Timer
functionality is completely built on XPLM: XPLMCreateFlightLoop
is used to create a timer.XPLMScheduleFlightLoop
schedules timers.XPLMDestroyFlightLoop
will clean up when a timer is done.