• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA Gauge Delays

mendiola_loyola

Resource contributor
Messages
520
Country
peru
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ú
 
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.
 
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...
 
Back
Top