• 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 Adding a timer.

Vololiberista, I just tried your code with the engine temp variation, reduced to 15 seconds, and it didnt work. Did I do something wrong?

Code,

Code:
<!-- Engine One -->
<Element>
      <Select>
        <Value>
              (L:RandomNumber,number) 0.115 &lt; if{ (L:eng1_stop,number) @GetElapsed(time1,seconds) +
             (A:TURB ENG ITT:1, celsius) 400 > *
             d (>L:eng1_stop,number) 15 > 
             if{ (>K:TOGGLE_ENGINE1_FAILURE) 0 (>L:eng1_stop,number) 1 (>L:restart1,bool) }
            @SetElapsed(time1,seconds) }
         </Value>
      </Select>
</Element>

<Element>
      <Select>
         <Value>
             (L:RandomNumber,number) 0.100 &lt; if{ (A:TURB ENG ITT:1, celsius) 390 &lt; (L:restart1,bool) 1 == and
              if{ 0 (>L:eng1_stop,number) 0 (>L:restart1,bool) (>K:TOGGLE_ENGINE1_FAILURE) } }
          </Value>
      </Select>
</Element>

* This would mean the seconds that it takes to overheat? ................ d (>L:eng1_stop,number) 15 > (15 being the seconds)


EDIT: I tried this code again, stock but changed high RPM limit to 95% (as my engines cannot do over 100) and again this didnt work. :(

So now that you are getting proficient at timers and triggering events, can you translate this for us back here in this dimension? Can you disect for instance, and explain in detail, how this cool code works?

I think your turbine ITT vars are not quite correct. You have (A:TURB ENG ITT:1, celsius) whereas I have (A:TURB ENG1 ITT, celsius)
 
Vololiberista,

I was experimenting with your failure code (timers). How on Earth did you get that to work?? One flight, it crashes at about 20 min's, another at nearly an hour. How do you scatter the times? I cannot see where you get that from in your code...

EDIT: Oddly, now I cannot seem to go to full throttle when on the ground.
Ok Leone,
It sets up when the master switch is put to ON.
Code:
<!-- Random Number Generator -->

<Macro Name="XMLRandom">(L:RandomSeed1,number) 0 == (L:RandomSeed2,number) 0 == ||
if{ (P:Absolute Time,seconds) abs d 2147483563 % (>L:RandomSeed1,number) sqrt d d * * abs 2147483599 % (>L:RandomSeed2,number) } (L:RandomSeed1,number) 40014 * 2147483563 % (>L:RandomSeed1,number) (L:RandomSeed2,number) 40692 * 2147483399 % (>L:RandomSeed2,number) (L:RandomSeed1,number) (L:RandomSeed2,number) - 2147483563 / s1 l1 0 &lt; if{ l1 ++ s1 } l1</Macro>

<Element>
      <Select>
         <Value>(L:switch_pos,bool) 1 == (L:ran,bool) 0 == and
if{ @XMLRandom (>L:RandomNumber,number) 1 (>L:ran,bool) }
els{ (L:switch_pos,bool) 0 == if{ 0 (>L:ran,bool) } }</Value>
      </Select>
   </Element>

The first element creates the random seed and the second drives the standby horizon failure
Code:
<!-- Standby Horizon needs Fast Erect -->
<Element>
      <Select>
         <Value>(L:RandomNumber,number) 0.105 &lt; (L:fast_erect,bool) 0 == and (L:switch_pos,bool) 1 == and
if{ -250 (>L:Attitude indicator bank degrees,number) }
els{ (A:Attitude indicator bank degrees,radians) (>L:Attitude indicator bank degrees,number) }</Value>
      </Select>
   </Element>

<Element>
      <Select>
         <Value>(L:RandomNumber,number) 0.055 &lt; (L:fast_erect,bool) 0 == and (L:Attitude indicator bank degrees,number) -250 == and (L:flight,enum) 1 == and
if{ (A:Attitude indicator bank degrees,radians) (>L:Attitude indicator bank degrees,number) 1 (>L:fast_erect,bool) }</Value>
      </Select>
   </Element>

So I've used the same var (L:RandomNumber,number). I tested it before I went to the UK and had no problems. The values of 0.1 or thereabouts equate to a 10% failure rate.
 
I think your turbine ITT vars are not quite correct. You have (A:TURB ENG ITT:1, celsius) whereas I have (A:TURB ENG1 ITT, celsius)
The FSX/ESP/P3D SDK shows: TURB ENG ITT:index (where index is engine number)
ENG1, ENG2, ENGn are deprecated...
 
Note that "deprecated" is not the same thing as being "eliminated." All such deprecated tokens were scheduled to be eliminated in the next version of FS, which as everyone knows never happened.
 
Note that "deprecated" is not the same thing as being "eliminated." All such deprecated tokens were scheduled to be eliminated in the next version of FS, which as everyone knows never happened.

Deprecated or not it works :) Whereas Leone's (apparently the correct code) didn't!!
 
Deprecated or not it works :) Whereas Leone's (apparently the correct code) didn't!!

Thats what happens when your brain ventures into the XML universe or dimension... Sometimes it gets all backwards.

The other day, if I put a 'and' where it should go, it didnt work, but leaving it out, it worked fine. Go figure.

What I am going to try to do (tomorrow morning) is rewrite this without the random number. What I want is for the timer to 'stop' when the temp goes back under limits, perhaps a total timer reset. The one I am running now just isnt working. I will be running cool and suddenly the engines both give out.
 
But....... That 'random number' concept is interesting. Perhaps another thread on just that topic. And another on how to cause engines and failures, lol...
 
But....... That 'random number' concept is interesting. Perhaps another thread on just that topic. And another on how to cause engines and failures, lol...
There was a thread about random numbers not so long ago. It might even be in the wiki now. I don't have time to check right now. I got the whole code from here.
After running the random number generator which I have at the start of my hidden code gauge I do two stages
@XMLRandom (>L:RandomNumber,number) which is for the fast errect
Thereafter (L:RandomNumber,number) 0.101 &lt; will work every time for any other need. The value 0.101 here represents about 10% failure.
 
Many thanks Vololiberista. And yes, that was added to the Wiki. There is a link to it in this thread. Many thanks man.

That is pretty genious, getting that to work in an instrument, attitude indicator.

I posed a question to 'Lionheart Creations' followers at my LHC page in Facebook, if they would like 'failures' on my planes (the new Lear) and some were for it and some against. And I thought.. What if I had a switch for turning failures (possible failures) "on"... So I did. I put a switch in that makes failures active. So, if I want the engines to be able to cook and stall, I flip on 'Realism Active' and Voila. Anything that has (L:activate realism,bool) in it as a requirement state will work and fire off during the flight. So for people (like me) that hate it when your plane fails and crashes, we can leave it off, and those that like to dare the engines failures can enjoy that possibility as well. With and without in the same plane.

Bill
 
Last edited:
Ok.. Back to timers. Can someone explain to me what this means?

(L:3308BootTime,enum) ++ (>L:3308BootTime,enum)

This evidently will begin a timer counting. How can ++ cause this? It seems like a complete mystery to me. Is there some basic explanation as to how this works?




Here is a Bill Leaming code that he had done for me (thanks Bill) which I incorporated into a PFD boot up screen. It basically runs the boot screen when the PFD is powered up, then the boot screen disappears. The core element of the code is above.

In this code, (L:3308BootTime,enum) will go to 260 counts which is around 20 seconds, roughly, (I changed it a little). So, is the count powered by the 18 cycles a second condition of the system? Every second, the counter clicks 18 times?

Code:
<!-- BOOT SCREEN -->
     <!-- Initialize all variables when power is OFF -->
    <Element>
       <Select>
        <Value>
        (A:Avionics Master Switch,bool) 0 == (A:Electrical Master Battery,bool) 0 == || if{
        0 (>L:3308BootScreen,enum)
        0 (>L:3308BootTime,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Start timer and increment when both battery and avionics are ON -->
    <Element>
            <Select>
        <Value>
        (A:Avionics Master Switch,bool) (A:Electrical Master Battery,bool) and (L:3308BootTime,enum) 260 &lt;= and
        if{ (L:3308BootTime,enum) ++ (>L:3308BootTime,enum) 1 (>L:3308BootScreen,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Stop timer after 20 seconds -->
    <Element>
       <Select>
         <Value> (L:3308BootTime,enum) 260 > if{ 0 (>L:3308BootScreen,enum) } </Value>
       </Select>
    </Element>

     <!-- While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Visible>(L:3308BootScreen,enum) 1 == </Visible>
                 <Position X="96" Y="41"/>
        <Image Name="Garmin_MFD_Bootup_screen.bmp" ImageSizes="769,602" Bright="Yes">
            </Image>
    </Element>


So basically, a very rough version of a timer is just; (L:3308BootTime,enum) ++ (>L:3308BootTime,enum) ?
 
Your LVAR (L:3308BootTime,enum) is simply a counter.

(L:3308BootTime,enum) ++ (>L:3308BootTime,enum) adds 1 to whatever is currently in (L:3308BootTime,enum) and puts the answer back in (L:3308BootTime,enum).

So far it cannot be called a timer.

The above addition takes place each time the code is processed.

If you can judge what that counter will have reached in a certain time, then it might be called a timer.

As you have pointed out, at 18 cycles, when the LVAR reaches 260 it has been running for 20 seconds, give or take the odd nanosecond.

To be called a timer it needs to be set going and monitored in some fashion.

If all this is done properly then you have something you might call a timer.

A timer is a thing of beauty and a joy to behold.

I am bored here with nothing else to do, so please forgive the long-winded answer - which may or may not answer your question.:(

Walter
 
A thousand thanks Walter. Massively appreciated. It helped me to understand this quite a bit better.


I just came upon a revelation of how another of Bills code works;

(L:Eng1Exceed906CNumCycles, enum) 18 60 * 20 * &gt;=

I know that it uses minutes via the * 20 * section being 20 min's. But I didnt know how. Now I do. An explanation for those (like me) that want to learn how this stuff works.

(L:Eng1Exceed906CNumCycles, enum) is the counter
18 60 * ..........is 18 X 60, which is 18 clicks (counts per 18 cycles per second) times 60. So, it is converting Hertz or counts per second (18) to 'minutes'.
20 * &gt;= ......... Times 20 (20 min's or 20 times the total of 18 X 60. So, this gives you 20 min's... (and greater then or equals to) at the end.

So... (L:Eng1Exceed906CNumCycles, enum) 18 60 * 20 * &gt;= means "timer" (18 X 60) X20 "equal to or greater then."
 
Ok, I have a working engine 'overheat' code that will also reset. I'll show those that are interested how it works.


Code is for an 'update' section;

Code:
     <!-- Initialize all variables when power is OFF -->
                (A:TURB ENG ITT:1, celsius) 410 &lt;
                (L:BOX OF TRICKS,bool) 0 == or
                    if{ 0 (>L:Engine1 Failure Timer,enum) }

     <!-- Start timer -->

                (A:TURB ENG ITT:1, celsius) 435 &gt;
                (L:BOX OF TRICKS,bool) 1 == and
                (L:Engine1Failure,bool) 0 == and
                    if{ (L:Engine1 Failure Timer,enum) ++ (>L:Engine1 Failure Timer,enum) }

     <!-- Activate engine failure at 20 seconds -->

                (L:Engine1 Failure Timer,enum) 18 60 * 1 * &gt;=
                    if{ 1 (>L:Engine1Failure,bool)
                          (>K:TOGGLE_ENGINE1_FAILURE)
                        0 (>L:Engine1 Failure Timer,enum)
                        1 (>L:Engine1 Cooldown Reset,bool) }

     <!-- Reset timer for engine restart -->

                (L:Engine1Failure,enum) 1 ==
                (L:Engine1 Cooldown Reset,bool) 1 == and
                    if{ (L:Engine1 Cooldown Reset Timer,enum) ++ (>L:Engine1 Cooldown Reset Timer,enum) }

     <!-- If Cooldown is done, make system reset -->

                (L:Engine1 Cooldown Reset Timer,bool) 18 60 * 1 * &gt;=
                (L:Engine1Failure,enum) 1 == and
                    if{ 0 (>L:Engine1 Cooldown Reset,bool)
                        0 (>L:Engine1 Cooldown Reset Timer,enum)
                        0 (>L:Engine1 Failure,enum)                      
                          (>K:TOGGLE_ENGINE1_FAILURE) }



This involves 2 timers; (L:Engine1 Failure Timer,enum) and.... (L:Engine1 Cooldown Reset Timer,enum).

These are presently set at 1 minute each; 1 minute to engine failure, and 1 minute after engine failure, of which recool has completed and engine can be restarted.

The minute setting is at * 1 *.. Changing that to say * 15 * will make it 15 minutes. (Probably what I will use for failure, then 2 minutes for cooldown)

Thanks everyone for help and input.

EDIT: Oddly, in testing the heck out of this, there is an anomaly going on with the time. If I set it at 1 min, it does that. If I set it at 5 min's, it takes 10 min's to fail. If at 15 min's, it takes like 40 min's to fail.
 
Last edited:
Many thanks Vololiberista. And yes, that was added to the Wiki. There is a link to it in this thread. Many thanks man.

That is pretty genious, getting that to work in an instrument, attitude indicator.

I posed a question to 'Lionheart Creations' followers at my LHC page in Facebook, if they would like 'failures' on my planes (the new Lear) and some were for it and some against. And I thought.. What if I had a switch for turning failures (possible failures) "on"... So I did. I put a switch in that makes failures active. So, if I want the engines to be able to cook and stall, I flip on 'Realism Active' and Voila. Anything that has (L:activate realism,bool) in it as a requirement state will work and fire off during the flight. So for people (like me) that hate it when your plane fails and crashes, we can leave it off, and those that like to dare the engines failures can enjoy that possibility as well. With and without in the same plane.

Bill

Of course the whole point of a flight simulator is to simulate failures and emergency drills. My model is at the moment undergoing an extensive refit. Ranging from new engine sounds and even new wide screen panels. The simmers that fly my VC10 don't have the luxury of being able to turn off failures. They happen (albeit rarely) and they have to deal with it according to the manuel. In a sense it's also a way of showing off the flying qualities of the aircraft. And, it's a way of teaching (demonstrating) airmanship skills. For example how do you cope with a bird strike at V1? It's all in the manuel!!
 
Of course the whole point of a flight simulator is to simulate failures and emergency drills. My model is at the moment undergoing an extensive refit. Ranging from new engine sounds and even new wide screen panels. The simmers that fly my VC10 don't have the luxury of being able to turn off failures. They happen (albeit rarely) and they have to deal with it according to the manuel. In a sense it's also a way of showing off the flying qualities of the aircraft. And, it's a way of teaching (demonstrating) airmanship skills. For example how do you cope with a bird strike at V1? It's all in the manuel!!

I agree but its nice to be able to just take a plane up and have it work nicely now and then. ;) I'll never forget that awesome Constellation for FS2004 that came out years ago. So awesome. I could NOT get a full flight in as it was always seizing up the engines. I hated that. Try as I may.....
 
I wonder if exhaust gas temp is not the best thing to use.. Its all over the place for me. Perhaps engine RPM is the best way to go for engine failure. That is a definate constant.
 
I wonder if exhaust gas temp is not the best thing to use.. Its all over the place for me. Perhaps engine RPM is the best way to go for engine failure. That is a definate constant.
In FS9 in C:\Documents and Settings\name\Application Data\Microsoft\FS9\AIRCRAFT\aircraft name, there is a file called state.cfg which is linked to
(A:GENERAL ENG ELAPSED TIME:xx, hours).

[engine.0]
accumulated_time=1665.043612
[engine.1]
accumulated_time=1697.584379
[engine.2]
accumulated_time=1729.806756
[engine.3]
accumulated_time=1716.942341
[FltSim.2]
atc_flight_number=2578
atc_heavy=0

I linked this with (A:TURB ENG1 VIBRATION, number) so that as the time accumulates the vibration increases gradually to a point where the engine will shut down.
 
I linked this with (A:TURB ENG1 VIBRATION, number) so that as the time accumulates the vibration increases gradually to a point where the engine will shut down.

How do you 'add' vibration, Vololiberista? I didnt find this command in Events in the SDK.
 
Back
Top