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

MSFS20 Adding a QNH indicator...?

Messages
123
Country
italy
Hi all :)
for the small airport I am creating I would like to add the qnh indicator.
For the runway in use I use two SimObjects linked, as a trigger condition, to the wind direction.
I could get the same result but the work would be very long (it would be about 140 objects, 140 xml files, 140 conditions, from 930 to 1070 hPa)

Anyone know if there is a faster and more elegant way to get this?

TIA ;)
Desktop Screenshot 2020.12.16 - 01.27.26.70.png
 
No idea if this works, but I would try it like this:
Create an animation with 10 steps for one digit (animate the UV-mapping). Place that digit/animation as many times in your model as necessary (4 for QNH, 2 for runway direction). A tiny bit of math in the xml could then select the correct animation step per digit (step nr. = digit).
 
Yes, this is the only way I too had thought at the moment.
4*10 numbers to do isn't so long,
but the animations to write in the xml file are always more than 100.
There may be a way faster and more elegant but sadly I'm not a coder :)
Thanks for the reply ;)
 
but the animations to write in the xml file are always more than 100.
I think we might not be quite on the same page yet ;-)

Let's say you need 4 digits for QNH which is 1023
The four animations would have to be set like this:
Anim1000frame = 1
Anim100frame = 0
Anim10frame = 2
Anim1frame = 3
These four values could be extracted directly out of the QNH variable. So ideally four lines of code should do it.

Example 1000 in Pseudocode:
Anim1000frame = int(QNH / 1000)
(The "int" converts a floating point number to an integer, effectively shaving off the fractional part.)

So what happens in that formula is:
1023 --(/1000)--> 1.023 --(int)--> 1

Example 10 in Pseudocode:
Anim10frame = (int(QNH / 10)) mod 10
(modulo is the remainder of a division by x)

Result:
1023 --(/10)--> 102.3 --(int)--> 102 --(mod 10)--> 2

The modulo operator is a %-sign in the simobject-code. What I don't know unfortunately is how data types are handled and converted (the "int" part in my pseudocode) - if QNH is already an integer, the conversion might not be necessary. And then there's the reverse polish notation to tackle...
 
So there this is what I meant by a more elegant solution 👍
In my ignorance of coders I would have written a code for each qnh (so more than 100) 😅
Your post has opened my eyes and I will try to follow this method.
I hope to find some time to try it these days.
Then I will come here to update on the developments.
For now, a big thank you 🙂
(QNH is a float)

qmh.png
 
Cool, hope it works.

Out of interest I did a quick search for possible operations and found this old thing which has a brief summary on "Expression Operators":

According to this (and because QNH is a float) I would try this succession of operators: near --> div --> mod (%)
1022.8 --(near)--> 1023 --(div 1000)--> 1
1022.8 --(near)--> 1023 --(div 10)--> 102 --(% 10)--> 2

btw: the description of modulo on the linked page seems wrong (even if it were different in P3D - the described way would be pretty useless). I used it with two operands in FS2020 and it worked as expected.
btw2: if it works you could use the same technique for your RWY indicator. My only creation of a simobject so far is a landing-tee. I guess the formula for your indicator would be similar to what I used.
 
again a big thank you mrbump 👍
I'll be able to post in the next few days what result I will have obtained
The link of expression operators can be useful, probably many are still valid, some not anymore
for example
P3D uses > for greater than, MSFS uses &gt
You can see this in the code of the rwy-in-use indicator, which I created using two different objects with numbers and using a visibility parameter related to the wind direction
XML:
<Code>(A:AMBIENT WIND DIRECTION, Degrees) 91 &gt;= (A:AMBIENT WIND DIRECTION, Degrees) 270 &lt; and if{ 1 } els{ 0 }</Code>
But this solution to make the QNH indicator would have been absurd 🙃
and you gave me a great hint :wizard:
I will report the results
ciao ;)
 
Last edited:
P3D uses > for greater than, MSFS uses &gt
Yes, but this has nothing to do with FS2020 and everything with the xml format. Because < and > are used as tag delimiters in xml these characters mustn't appear in the data sections. %gt; and &lt; are the substitutions that are used (HTML encoding).
 
Back
Top