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

P3D v4 DME range needle

rotorhub

Resource contributor
Messages
126
Country
norway
I am trying to make a DME needle gauge (VC) to read 20NM or 200NM range, according to the switch setting.

Any tip on where I am failing?

Rotorhub

Code:
    <Animation name="DME_Range_Sw_1" guid="27d2bbfc-32cc-4af3-8dab-f91259053d54" type="Sim" typeParam="AutoPlay" length="50" typeParam2="DME_Range_Sw_1"/>

    <PartInfo>
    <Name>DME_Range_Sw_1</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:DME_Range_Sw_1, number) 50 *</Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <TooltipText>DME Range Select = %((L:DME_Range_Sw_1, number) 0 ==)%{if}20%{else}200%{end}</TooltipText>
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>(L:DME_Range_Sw_1, number) ! (>L:DME_Range_Sw_1, number)</CallbackCode>
    </MouseRect>
  </PartInfo>

    <Animation name="T4_NAV_DME" guid="bcabc948-6a6e-41ef-b093-ffbf4d756fc8" length="100" type="Sim" typeParam2="T4_NAV_DME" typeParam="AutoPlay" />
  <PartInfo>
    <Name>T4_NAV_DME</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
        (L:DME_Range_Sw_1, number) 0 == if{
            (A:NAV DME:1, nautical miles) 0 max 20 min 5 * (A:CIRCUIT AVIONICS ON, bool) *) <!-- DME 20 --> 
            } els{ 
            (L:DME_Range_Sw_1, number) 1 == 
            } if{
            (A:NAV DME:1, nautical miles) 0 max 200 min 0.5 * (A:CIRCUIT AVIONICS ON, bool) * <!-- DME 200 -->
            }
        </Code>
        <Lag>500</Lag>
      </Parameter>
    </Animation>
  </PartInfo>
 
Just a quick look..
1) The part "T4_NAV_DME" seems to be missing the attribute typeParam2=" " in the animation header.
2) The If-Else-IF in the animation code seems wonky.
2a) If you want an IF-ELSE-IF then it should be :
if{ } els{ if{ }} (note the second if is enclosed in the els braces)
XML:
        <Code>
        (L:DME_Range_Sw_1, number) 0 == if{
            (A:NAV DME:1, nautical miles) 0 max 20 min 5 * (A:CIRCUIT AVIONICS ON, bool) *) <!-- DME 20 -->
            } els{
            (L:DME_Range_Sw_1, number) 1 ==
            if{
            (A:NAV DME:1, nautical miles) 0 max 200 min 0.5 * (A:CIRCUIT AVIONICS ON, bool) * <!-- DME 200 -->
            } }
        </Code>
2b) Since the var DME_Range_Sw_1 is basically a boolean you can get away with just an if{ } els{ }
XML:
        <Code>
        (L:DME_Range_Sw_1, number) 0 == if{
            (A:NAV DME:1, nautical miles) 0 max 20 min 5 * (A:CIRCUIT AVIONICS ON, bool) *) <!-- DME 20 -->
            } els{           
            (A:NAV DME:1, nautical miles) 0 max 200 min 0.5 * (A:CIRCUIT AVIONICS ON, bool) * <!-- DME 200 -->
            }
        </Code>

Roman
 
Thank you very much for your help! The switch now trigger the needle, but the values don't seem to work as I anticipated.
Both codes work correctly used on their own, but used together the range scaling gets messed up (see picture)?
I have tried both / and * to set correct value at keyframe 100.

The gauge max value can be read as 20 or 200, according to the switch setting. In my example 64 NM out, the 200 setting shows the correct range, but the 20 setting should peg the needle. It is more than 20 NM to the station.

Rotorhub
DME_Gauge.jpg

Code:
        (L:DME_Range_Sw_1, number) 0 == if{
            (A:NAV DME:1, nautical miles) 0 max 20 min 5 * (A:CIRCUIT AVIONICS ON, bool) *) <!-- DME 20 -->
            } els{           
            (A:NAV DME:1, nautical miles) 0 max 200 min 2 / (A:CIRCUIT AVIONICS ON, bool) * <!-- DME 200 -->
            }
 
Perhaps try to remove the ")" in this line :
....ONICS ON, bool) *) <!-- DME 20 -->
It really shouldn't be there.
 
Back
Top