• 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.

XML if / els format question

Messages
160
From looking around it would seem you don't HAVE to have an els condition, so bearing that in mind, anything wrong with this syntax?

<code>
(G:Var1) 0 == if{ (A:VELOCITY BODY Z,knots) 80 &lt; if{ (A:LIGHT NAV,bool) 15 * } els{ 1 (&gt;G:Var1) 0 } }
(G:Var1) 1 == if{ (A:RADIO HEIGHT,feet) 1500 &gt; (A:VELOCITY BODY Z,knots) 300 &lt; and if{ 2 (&gt;G:Var1) 0 } els{ 0 } }
(G:Var1) 2 == if{ 600 290 (A:VELOCITY BODY Z,knots) rng if{ 10 }
els{ 289 270 (A:VELOCITY BODY Z,knots) rng if{ 20 }
els{ 269 240 (A:VELOCITY BODY Z,knots) rng if{ 40 }
els{ 239 200 (A:VELOCITY BODY Z,knots) rng if{ 80 }
els{ 199 0 (A:VELOCITY BODY Z,knots) rng (A:LIGHT STROBE,bool) and 100 * } } } } }
els{ 0 }
</code>

Or would this be correct?

<code>
(G:Var1) 0 == if{ (A:VELOCITY BODY Z,knots) 80 &lt; if{ (A:LIGHT NAV,bool) 15 * } els{ 1 (&gt;G:Var1) 0 } }
(G:Var1) 1 == if{ (A:RADIO HEIGHT,feet) 1500 &gt; (A:VELOCITY BODY Z,knots) 300 &lt; and if{ 2 (&gt;G:Var1) 0 } els{ 0 } }
(G:Var1) 2 == if{
300 270 (A:VELOCITY BODY Z,knots) rng 10 *
269 200 (A:VELOCITY BODY Z,knots) rng 40 * ||
199 0 (A:VELOCITY BODY Z,knots) rng (A:LIGHT STROBE,bool) and 100 * ||
}
els{ 0 }
</code>
 
Last edited:
Code:
         (A:Airspeed select indicated or true,knots) 20 &gt; (L:Oat, bool) &amp;&amp; s1  

        (A:Airspeed select indicated or true,knots) 19 &gt; (L:static, bool) &amp;&amp; s2 

        (A:Airspeed select indicated or true,knots) 10 &gt; (L:Heat, bool) &amp;&amp; s3

        (A:Airspeed select indicated or true,knots) 10 &gt; (L:Air, bool) &amp;&amp; s4

	(A:Airspeed select indicated or true,knots) 20 &gt; (L:RightOat, bool) &amp;&amp; s5


        l1 l2 || l3 || l4 || l5 || if{ 2 (&gt;L:XMLSND5,bool) } els{ 3 (&gt;L:XMLSND5,bool) }

I looked at a code i had using 5 events to cause a sound to play or stop.
I thought you could maybe implement this for your lower half of the code.

The upper half i noticed u used a 15 * for a bool.....(A:LIGHT NAV,bool) 15 *
maybe just make it 1==, since it only knows off and on.

:idea:
 
<code>
(G:Var1) 0 == if{ (A:VELOCITY BODY Z,knots) 80 &lt; if{ (A:LIGHT NAV,bool) 15 * } els{ 1 (&gt;G:Var1) 0 } }
(G:Var1) 1 == if{ (A:RADIO HEIGHT,feet) 1500 &gt; (A:VELOCITY BODY Z,knots) 300 &lt; and if{ 2 (&gt;G:Var1) 0 } els{ 0 } }
(G:Var1) 2 == if{
300 270 (A:VELOCITY BODY Z,knots) rng 10 *
269 200 (A:VELOCITY BODY Z,knots) rng 40 * ||
199 0 (A:VELOCITY BODY Z,knots) rng (A:LIGHT STROBE,bool) and 100 * ||
}
els{ 0 }
</code>

This code is fine. Notice what I enhanced in red; as both logical conditions include 0 it is preferable to write:

(G:Var1) 1 == if{ (A:RADIO HEIGHT,feet) 1500 &gt; (A:VELOCITY BODY Z,knots) 300 &lt; and if{ 2 (&gt;G:Var1) } 0 }

Tom
 
Thanks,
Still not sure my last section of code will work as intended.

eg
0 10 (A:VELOCITY BODY Z,knots) rng if{ 100 } els{ 0 } - I know is ok
0 10 (A:VELOCITY BODY Z,knots) rng 100 * - Would return either 0 or 100 (I think)

So....
0 10 (A:VELOCITY BODY Z,knots) rng 10 *
11 20 (A:VELOCITY BODY Z,knots) rng 20 * ||

Neither one would return a 1 (true) for the || operation, its either 0, 10, or 20 - So how would it decide which one to use?
I only want one or the other i.e. 10 or 20.

so would I get away wth -
(G:Var1) 2 == if{
(A:VELOCITY BODY Z,knots) 900 &gt: if{ 0 }
180 900 (A:VELOCITY BODY Z,knots) rng if{ 10 }
150 179 (A:VELOCITY BODY Z,knots) rng if{ 40 }
0 149 (A:VELOCITY BODY Z,knots) rng (A:LIGHT STROBE,bool) and if{ 100 }
}
 
Last edited:
Thanks,
Still not sure my last section of code will work as intended.

eg
0 10 (A:VELOCITY BODY Z,knots) rng if{ 100 } els{ 0 } - I know is ok
0 10 (A:VELOCITY BODY Z,knots) rng 100 * - Would return either 0 or 100 (I think)

You think right. 0 10 (A:VELOCITY BODY Z,knots) rng is a boolean conditional that can only return 0 or 1, which when multiplied by 100 will give 0 or 100.


So....
0 10 (A:VELOCITY BODY Z,knots) rng 10 *
11 20 (A:VELOCITY BODY Z,knots) rng 20 * ||

Neither one would return a 1 (true) for the || operation, its either 0, 10, or 20 - So how would it decide which one to use?
I only want one or the other i.e. 10 or 20.

If you want to use 10 or 20 here, you should replace || with + :
0 10 (A:VELOCITY BODY Z,knots) rng 10 *
11 20 (A:VELOCITY BODY Z,knots) rng 20 * +

Personally I've used this kind of approach in many snippets (certainly more complex than this one)

so would I get away wth -
(G:Var1) 2 == if{
(A:VELOCITY BODY Z,knots) 900 &gt: if{ 0 }
180 900 (A:VELOCITY BODY Z,knots) rng if{ 10 }
150 179 (A:VELOCITY BODY Z,knots) rng if{ 40 }
0 149 (A:VELOCITY BODY Z,knots) rng (A:LIGHT STROBE,bool) and if{ 100 }
}

This is ok as well, and with no doubt easier to understand (classic style)
BTW, remember (A:VELOCITY BODY Z,knots) is float (has decimals) so you should care of what to do when it reads 179.50, for example ;)

Tom
 
Ahhh I had forgotten it was a float!
I re- wrote using if/els in place of the rng statements.
Thanks.

Last one if I may -
Bank angle is measured 0-359 degrees.
Any idea on pitch angle?
Also I have seen it using both degrees or radians as thee measurement unit?

Cheers
 
I seem to remember pitch being measured from -180 to +180 with negative being nose up from when I was playing around with it.

You can use degrees or radians, it really depends what you plan on doing with it, most of the trig functions available in XML work on radians but if you're just comparing values against a limit then degrees are fine.
 
Thanks.

Opposite to what you would expect - minus for pitch down, plus for pitch up, I wonder what they were thinking of!

On the bank angle 0->359 is that right wing down?
Or opposite for lefties like me LOL.

I know that there is lots in the SDK, but never have found anything that would tell you for PITCH - was nose up and + was nose down.

Unless I missed something somewhere along the way.
 
The Pitch range is -90 to +90 degrees. The attached chart is a view of an inside loop. You can see how Heading, Bank, and Pitch behave throughout the loop.

Also attached are charts that show Bank degrees throughout a Left and Right barrel roll. Bank range is -180 to +180 degrees.

The SDK helps for some things, the rest is learn-as-you-go. Test, test, test.

Bob
 

Attachments

  • INSIDE LOOP.jpg
    INSIDE LOOP.jpg
    94.7 KB · Views: 509
  • ROLL LEFT.jpg
    ROLL LEFT.jpg
    24 KB · Views: 396
  • ROLL RIGHT.jpg
    ROLL RIGHT.jpg
    30.7 KB · Views: 474
Last edited:
Back
Top