FSXA Gauge Delays

mendiola_loyola

Resource contributor
#1
Dear All:

Is there a way to create a delay in a c gauge.

I want to start a light with a switch, but i want to turn on the light after 3 seconds of have pushed the switch.

In c++ please.

Can i use sleep(n); ?

Thanks
Alfredo Mendiola Loyola
Lima, Perú
 

Lefteris Kalamaras

Administrator
Staff member
FSDevConf team
#2
Dear All:

Is there a way to create a delay in a c gauge.

I want to start a light with a switch, but i want to turn on the light after 3 seconds of have pushed the switch.

In c++ please.

Can i use sleep(n); ?

Thanks
Alfredo Mendiola Loyola
Lima, Perú
Alfredo-

sleep() will cause the thread to pause - if that's inside a PRE_UPDATE or a PRE_DRAW (or anywhere in the same FS thread), the entire app will seem to pause and stutter.

What you need is a variable that checks time-passed, which you'll initialize when you flick the switch, and check continuously. When sufficient time has passed (use FS time, rather than Windows time), you can flick it back.
 

n4gix

Resource contributor
#3
There are many ways to create a timer. The most basic is to base it on the tick18 variable, understanding that a value of 54 is roughly 3 seconds (18x3=54).

The better way is to use the token variable ELAPSED SECONDS. The chief reason being that the timer will automatically pause if the sim is paused...
 
Top