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

Trying to make a simple FLCH gauge (P3D)

Messages
28
Country
us-indiana
I'm trying to make a simple FLCH gauge. I know the basics of gauge coding at this point, and mathematically, what I have come up with makes total sense. But when I run the gauge in the sim, it doesn't continue to reiterate the gauge operation (see <update> section). The concept is as follows:

1) Click the gauge button (FLCH). Instantaneous airspeed and vertical speed are sent to the autopilot panel. FD follows suit to match VS.

2) The math: Current IAS is subtracted from the now preselected IAS, and then the result is divided by the preselected IAS. The result, a percentage essentially, is multiplied against the now preselected VS. This results in a+/- correction, which is then added to the preselected VS, whose result should then be sent to the AP panel. But the gauge stops working after step one. Nothing happens after that. VS stays pegged at whatever the gauge was switched on at. What's going on?

Thank you for your help!

The code:

<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="1,0" id="FLCH_Button">
<Descr>FLCH Button</Descr>
<Filename>FLCH_Button.xml</Filename>
<SimGauge.Gauge id="FLCH_Button" ArtDirectory="Gauges">
<FloatPosition>0.000,0.000</FloatPosition>
<Size>80,40</Size>
<Image id="flch_button.bmp" Name="flch_button.bmp">
<Transparent>True</Transparent>
</Image>

<MouseArea>
<FloatPosition>0.000,0.000</FloatPosition>
<Size>80,40</Size>
<CursorType>Hand</CursorType>
<MouseClick>
<Script>
(L:FLCH_Active, bool) ! (>L:FLCH_Active, bool)
(L:FLCH_Active, bool) if{
(A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
(A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)
(A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH)
(A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
(A:AUTOPILOT VERTICAL HOLD VAR, feet per minute) (>L:VerticalSpeed, number)
(
}
els{
0 (>L:FLCH_Active, bool)
}
</Script>
</MouseClick>
</MouseArea>

<Update>
(L:FLCH_Active, bool) if{
(A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
(A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
(L:TargetAirspeed, number) (L:CurrentAirspeed, number) - (>L:SpeedDifference, number)
(L:SpeedDifference, number) (L:TargetAirspeed, number) / (>L:SpeedErrorPercentage, number)
(L:SpeedErrorPercentage, number) (L:VerticalSpeed, number) * (>L:VSAdjustment, number)
(L:VerticalSpeed, number) (L:VSAdjustment, number) + (>L:NewVS, number)
(L:NewVS, number) (>K:AP_VS_VAR_SET_ENGLISH)
}
</Update>
</SimGauge.Gauge>
</SimBase.Document>
 
First, you have an extra '{' just two lines above your 'els{' line. Second, unless I'm wrong about variable order... your line where you calculate your SpeedDifference may be sign reversed in it's result. As example:

Code:
CurrentAirspeed = 150
TargetAirspeed = 140
SpeedDifference = -10
SpeedErrorPercentage = -0.07143
VerticalSpeed = 1000
VSAdjustment = -71.4286
NewVS = 928.5714

That will result in an increase in speed when you should be decreasing speed.
 
First, you have an extra '{' just two lines above your 'els{' line. Second, unless I'm wrong about variable order... your line where you calculate your SpeedDifference may be sign reversed in it's result. As example:

Code:
CurrentAirspeed = 150
TargetAirspeed = 140
SpeedDifference = -10
SpeedErrorPercentage = -0.07143
VerticalSpeed = 1000
VSAdjustment = -71.4286
NewVS = 928.5714

That will result in an increase in speed when you should be decreasing speed.
I did notice that math after the fact as well as the stray parenthesis after posting. Deleting that did not do anything. The other thing is even if the math works incorrectly, it seems I would see that on the gauge, but I don’t. It won’t even update to the next cycle of running.
 
Suggestion:

XML:
<Script>
    (L:FLCH_Active, bool) if{
        0 (>L:FLCH_Active, bool)
    }
    els{
        1 (>L:FLCH_Active, bool)
        (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)
        (A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH)
        (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
        (A:AUTOPILOT VERTICAL HOLD VAR, feet per minute) (>L:VerticalSpeed, number)
    }
</Script>
 
Suggestion:
XML:
<Script>
    (L:FLCH_Active, bool) if{
        0 (>L:FLCH_Active, bool)
    }
    els{
        1 (>L:FLCH_Active, bool)
        (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)
        (A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH)
        (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
        (A:AUTOPILOT VERTICAL HOLD VAR, feet per minute) (>L:VerticalSpeed, number)
    }
</Script>
Gave this a shot. Does not provide any joy. Still stuck on VS that the gauge was switched on at.
 
Last edited:
Rewrote code to this:
XML:
<?xml version="1.0" encoding="UTF-8"?>



<SimBase.Document Type="AceXML" version="1,0" id="FLCH_Button">

    <Descr>FLCH Button</Descr>

    <Filename>FLCH_Button.xml</Filename>

    <SimGauge.Gauge id="FLCH_Button" ArtDirectory="Gauges">

        <FloatPosition>0.000,0.000</FloatPosition>

        <Size>80,40</Size>

        <Image id="flch_button.bmp" Name="flch_button.bmp">

            <Transparent>True</Transparent>

        </Image>



        <MouseArea>

            <FloatPosition>0.000,0.000</FloatPosition>

            <Size>80,40</Size>

            <CursorType>Hand</CursorType>

            <MouseClick>

                <Script>

                    (A:AUTOPILOT ALTITUDE HOLD, bool) 0 ==

                    if {

                        (>K:AP_PANEL_ALTITUDE_HOLD)

                    }



                    (L:FLCH_Active, bool) if {

                        0 (>L:FLCH_Active, bool)

                    }

                    els {

                        1 (>L:FLCH_Active, bool)

                        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)

                        (A:ATTITUDE INDICATOR PITCH DEGREES, radians) (>K:AP_ATT_HOLD)

                        (A:ATTITUDE INDICATOR PITCH DEGREES, radians) (>K:AP_PITCH_REF_SELECT)

                    }

                </Script>

            </MouseClick>

        </MouseArea>



        <Update>

            (L:FLCH_Active, bool) if {

                (A:AUTOPILOT ALTITUDE HOLD, bool) 1 ==

                if {

                    (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)

                    (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)

                    (L:CurrentAirspeed, number) (L:TargetAirspeed, number) <

                    if {

                    (>K:AP_PITCH_REF_INC_DN)

                    }

                    els {

                        (L:CurrentAirspeed, number) (L:TargetAirspeed, number) >

                        if {

                            (>K:AP_PITCH_REF_INC_UP)

                        }

                    }

                }

            }

        </Update>

    </SimGauge.Gauge>

</SimBase.Document>



But now the gauge doesn't show up in FS at all. Moreover, Notepad++ is showing

XML:
                    if {

                    (>K:AP_PITCH_REF_INC_DN)

                    }

as an invalid statement and it fails to properly close the nesting.

Doesn't make any sense.

Tips?

EDIT: Put the code through an online XML editor and it detects the nestings appropriately. Leading me to think there is no issue with the code. But what is interesting is with the current code, the FLCH button has disappeared from my panel, and there's no reason why it shouldn't be there. The previous iteration of code that I had had no issues with the gauge visibility. Not only do I see nothing, but the clickspot is gone also. It's as if the gauge is not in the panel. Also makes no sense.

EDIT 2: Figured out that < is not the ideal thing to use in XML gauge editing and was causing problems with the next If{ statement. I've replaced the < and > signs with &lt and &gt. So now that issue is solved. But for some reason the button is still not showing up on the panel. Code as of now:


XML:
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="1,0" id="FLCH_Button">
    <Descr>FLCH Button</Descr>
    <Filename>FLCH_Button.xml</Filename>
    <SimGauge.Gauge id="FLCH_Button" ArtDirectory="Gauges">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Size>80,40</Size>
        <Image id="flch_button.bmp" Name="flch_button.bmp">
            <Transparent>True</Transparent>
        </Image>

        <MouseArea>
            <FloatPosition>0.000,0.000</FloatPosition>
            <Size>80,40</Size>
            <CursorType>Hand</CursorType>
            <MouseClick>
                <Script>
                    (A:AUTOPILOT ALTITUDE HOLD, bool) 0 ==
                    if {
                        (>K:AP_PANEL_ALTITUDE_HOLD)
                    }

                    (L:FLCH_Active, bool) if {
                        0 (>L:FLCH_Active, bool)
                    }
                    els {
                        1 (>L:FLCH_Active, bool)
                        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)
                        (A:ATTITUDE INDICATOR PITCH DEGREES, radians) (>K:AP_ATT_HOLD)
                        (A:ATTITUDE INDICATOR PITCH DEGREES, radians) (>K:AP_PITCH_REF_SELECT)
                    }
                </Script>
            </MouseClick>
        </MouseArea>

        <Update>
            (L:FLCH_Active, bool) if {
                (A:AUTOPILOT ALTITUDE HOLD, bool) 1 ==
                if {
                    (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
                    (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
                    (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &lt
                    if{
                        (>K:AP_PITCH_REF_INC_DN)
                    }
                    els {
                        (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &gt
                        if {
                            (>K:AP_PITCH_REF_INC_UP)
                        }
                    }
                }
            }
        </Update>
    </SimGauge.Gauge>
</SimBase.Document>
 
Last edited:
if {

(>K:AP_PITCH_REF_INC_DN)

}

there is a space between the if and the {

it appears that way a number of times and even with the els {

Maybe syntax has changed but I never found these to work in my own XML coding.

Walter
 
if {

(>K:AP_PITCH_REF_INC_DN)

}

there is a space between the if and the {

it appears that way a number of times and even with the els {

Maybe syntax has changed but I never found these to work in my own XML coding.

Walter
Possible that may have caused the issue I suppose. But the previous code iteration also had spaces in the syntaxes and the gauge appeared fine. I’ll remove the spaces later today and try again.
 
Removed all spaces in if, else statements. No luck.

Edit: added ; after &lt, &gt, gauge shows up now... testing again!

Edit 2: Tested. Not working. <sigh>

Edit 3: I've also altered the code as follows:

XML:
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="AceXML" id="FLCH_Button">
    <Descr>FLCH Button</Descr>
    <Filename>FLCH_Button.xml</Filename>
    <SimGauge.Gauge id="FLCH_Button" ArtDirectory="Gauges">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Size>80,40</Size>
        <Image id="flch_button.bmp" Name="flch_button.bmp">
            <Transparent>false</Transparent>
        </Image>

        <MouseArea>
            <FloatPosition>0.000,0.000</FloatPosition>
            <Size>80,40</Size>
            <CursorType>Hand</CursorType>
            <MouseClick>
                <Script>
                    (L:FLCH_Active, bool) if{
                        0 (>L:FLCH_Active, bool)
                    }
                    els{
                        1 (>L:FLCH_Active, bool)
                    }
                </Script>
            </MouseClick>
        </MouseArea>

        <Update>
            (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)   
            (A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH)           
            (L:FLCH_Active, bool) if{
                (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
                (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
                (A:VERTICAL SPEED, feet per minute) (>L:CurrentVS, number)
                (A:AUTOPILOT ALTITUDE LOCK VAR, feet) (>L:TargetAltitude, number)
                (A:PLANE ALTITUDE, feet) (>L:CurrentAltitude, number)
                (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &gt;
                if{
                    (>K:AP_PANEL_VS_HOLD)
                    (>K:AP_VS_VAR_INC)
                }
                els{
                    (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &lt;
                    if{
                        (>K:AP_PANEL_VS_HOLD)
                        (>K:AP_VS_VAR_DEC)
                    }
                }
                (L:TargetAltitude, number) (L:CurrentAltitude, number) - abs (>L:AltitudeDifference, number)
                (L:AltitudeDifference, number) 1000 &lt;
                if{
                    (>K:AP_ALT_HOLD_ON)
                }
            }
        </Update>
    </SimGauge.Gauge>
</SimBase.Document>

Still doesn't work, but I expected that.
 
Last edited:
Still does not work. At best, I get a pitch hold button. Yay.

Why did P3D not ship with a proper FLCH mode? Most jets don't even have A/T anyway. Ugh.

XML:
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="AceXML" id="FLCH_Button">
    <Descr>FLCH Button</Descr>
    <Filename>FLCH_Button.xml</Filename>
    <SimGauge.Gauge id="FLCH_Button" ArtDirectory="Gauges">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Size>80,40</Size>
        <Image id="flch_button.bmp" Name="flch_button.bmp">
            <Transparent>false</Transparent>
        </Image>

        <MouseArea>
            <FloatPosition>0.000,0.000</FloatPosition>
            <Size>80,40</Size>
            <CursorType>Hand</CursorType>
            <MouseClick>
                <Script>
                    (L:FLCH_Active, bool) if{
                        0 (>L:FLCH_Active, bool)
                    }
                    els{
                        1 (>L:FLCH_Active, bool)
                        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET)
                        (A:PLANE PITCH DEGREES, degrees) (>K:SYNC_FLIGHT_DIRECTOR_PITCH)
                        (>K:AP_ALT_HOLD)
                    }
                </Script>
            </MouseClick>
        </MouseArea>

        <UpdateFrequency>50</UpdateFrequency>
        <Update>

            (L:FLCH_Active, bool) if{
                (A:AIRSPEED INDICATED, knots) (>L:CurrentAirspeed, number)
                (A:VERTICAL SPEED, feet per minute) (>L:CurrentVS, number)
                (A:AUTOPILOT AIRSPEED HOLD VAR, knots) (>L:TargetAirspeed, number)
                (A:AUTOPILOT ALTITUDE LOCK VAR, feet) (>L:TargetAltitude, number)
                (A:PLANE ALTITUDE, feet) (>L:CurrentAltitude, number)
                (A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH)
             

                (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &gt;
                if{
                    (>K:AP_PANEL_VS_HOLD)
                    (>K:AP_VS_VAR_INC)
                }
                els{
                    (L:CurrentAirspeed, number) (L:TargetAirspeed, number) &lt;
                    if{
                        (>K:AP_PANEL_VS_HOLD)
                        (>K:AP_VS_VAR_DEC)
                    }
                }


                (L:TargetAltitude, number) (L:CurrentAltitude, number) - abs (>L:AltitudeDifference, number)
                (L:AltitudeDifference, number) 1000 &lt;
                if{
                    (>K:AP_ALT_HOLD_ON)
                }
            }
        </Update>
    </SimGauge.Gauge>
</SimBase.Document>
 
I do not believe I have ever seen VS hold function. To maintain a desired VS... altitude hold and then manipulate the VS value.
 
I do not believe I have ever seen VS hold function. To maintain a desired VS... altitude hold and then manipulate the VS value.
Then is there a reason gauge wise to even have the sim variable for VS then?

Utilizing the pitch hold increase and decrease don’t work either. Pretty sure I’m out of options here.
 
Pitch hold is almost impossible to get to work correctly. I say almost because it doesn't respond to any requested change of less than 1.5 degrees. At least, I could never get it to respond to anything less than that. I coded to overshoot the required pitch change and then come back to what was really required. It works - most of the time.

The last known version where VS Hold worked was FS2002. When I queried Lockheed-Martin back in version 4.5 if they were going to fix it, they responded that the bug is buried so deep that it's unfixable. There's no longer any mention of it in the SDK, but they can't take it out of the gauge enumeration because it would really screw things up. As Ed says, to lock in a vertical speed you need to first set an unfeasibly high altitude target (zero feet if descending), then set the vertical speed target and finally turn altitude hold on. In C/C++ it looks like this:
Code:
if(vsi_target > 0)trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 1000000); //Positive VS
else trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 0);                                //Negative VS
trigger_key_event(KEY_AP_VS_VAR_SET_ENGLISH, (int)vsi_target);                    //Set required VS
trigger_key_event(KEY_AP_ALT_HOLD_ON, 0);                                                   //Set alt hold on
Ideally you'd wrap in a function (or a macro in your case) but for some reason best known to the sim, it wouldn't work for me when wrapped as a function.
 
Pitch hold is almost impossible to get to work correctly. I say almost because it doesn't respond to any requested change of less than 1.5 degrees. At least, I could never get it to respond to anything less than that. I coded to overshoot the required pitch change and then come back to what was really required. It works - most of the time.

The last known version where VS Hold worked was FS2002. When I queried Lockheed-Martin back in version 4.5 if they were going to fix it, they responded that the bug is buried so deep that it's unfixable. There's no longer any mention of it in the SDK, but they can't take it out of the gauge enumeration because it would really screw things up. As Ed says, to lock in a vertical speed you need to first set an unfeasibly high altitude target (zero feet if descending), then set the vertical speed target and finally turn altitude hold on. In C/C++ it looks like this:
Code:
if(vsi_target > 0)trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 1000000); //Positive VS
else trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 0);                                //Negative VS
trigger_key_event(KEY_AP_VS_VAR_SET_ENGLISH, (int)vsi_target);                    //Set required VS
trigger_key_event(KEY_AP_ALT_HOLD_ON, 0);                                                   //Set alt hold on
Ideally you'd wrap in a function (or a macro in your case) but for some reason best known to the sim, it wouldn't work for me when wrapped as a function.
Sooo I guess what’s the best suggestion with this? Appreciate the insight… I’m dealing with a bug. Go figure. At least now I can stop scratching my head over why it won’t work. From there, you’re saying I should code this as a macro?
 
You can try it. I don't do XML so I have no idea if you will hit the same problem that I did. I'm not aware of any airfields below sea level (e.g. Aden) where VS hold would still be engaged below zero feet.
 
You can try it. I don't do XML so I have no idea if you will hit the same problem that I did. I'm not aware of any airfields below sea level (e.g. Aden) where VS hold would still be engaged below zero feet.
Coming back to this problem several months later because I got out the CRJ-200 by VirtualCol once again this year. If only I could get that a FLCH gauge on that thing, I would fly it a lot more than once a year!

Nothing I am doing seems to work. Even copy pasted Carenado's CE560XL AP panel over just to test it and see what it would do... no joy. It just captures the current IAS and levels the airplane off. This is exactly what happens when I use my code that I have come up with.

I am so confused as to why every iteration of FS up to MSFS 2020 has never had a flight level change built into the default AP. Who in their right mind would climb out at vertical speed during a busy departure with no copilot if the plane didn't have autothrottles? I try to avoid using A/T if the plane doesn't actually have it, but having to futz with the VS knob to hold a given airspeed without stalling or overspeeding at MCT fresh after departure whilst trying to keep the camera from zooming in and out and Vatsim telling me to switch over to departure is an absolute headache! If only I knew how to fix this problem... ugh! End rant lol
 
I created autopilot code for several aircraft, most of which are used in real world pilot training. It includes FLCH behavior. Probably my most well-known aircraft with autopilot was the Eaglesoft Citation X v2 for FSX. I did the flight dynamics and all gauge/systems coding for that addon.

I can assure you it's possible to code FLCH, but to do so... you have to truly understand both how the real autopilot works as well as how to get around the limitations of the sim's autopilot.
 
I created autopilot code for several aircraft, most of which are used in real world pilot training. It includes FLCH behavior. Probably my most well-known aircraft with autopilot was the Eaglesoft Citation X v2 for FSX. I did the flight dynamics and all gauge/systems coding for that addon.

I can assure you it's possible to code FLCH, but to do so... you have to truly understand both how the real autopilot works as well as how to get around the limitations of the sim's autopilot.
Great airplane!

Speak of the devil, I actually cracked the code tonight. Anyone else who wants it is more than free to use it!


It works like a charm... not terribly smooth, but it works!!!

XML:
<SimBase.Document Type="AceXML" version="1,0" id="FLCH_Gauge">
    <Descr>Flight Level Change Gauge</Descr>
    <Filename>FLCH_Gauge_Debug.xml</Filename>
    <SimGauge.Gauge id="FLCH_Gauge" ArtDirectory="Gauges">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Size>64,32</Size>

        <!-- Display Images -->
        <Image Name="FLCH_Off.bmp">
            <Transparent>false</Transparent>
        </Image>

        <!-- Mouse Interaction -->
        <MouseArea>
            <FloatPosition>0.000,0.000</FloatPosition>
            <Size>64,32</Size>
            <CursorType>Hand</CursorType>
            <Tooltip>FLCH Button</Tooltip>
            <MouseClick>
                <Script>
                    <!-- Toggle FLCH State -->
                    (L:FLCH_Active, bool) ! (>L:FLCH_Active, bool)

                    <!-- If Activated -->
                    (L:FLCH_Active, bool) 1 == if{
                        (A:AIRSPEED INDICATED, knots) (>K:AP_SPD_VAR_SET) <!-- Sync Preselected Speed -->
                        (A:VERTICAL SPEED, feet per minute) (>K:AP_VS_VAR_SET_ENGLISH) <!-- Sync Current VS -->
                        (>K:AP_VS_HOLD_ON) <!-- Engage VS Hold -->
                    }

                    <!-- If Deactivated -->
                    (L:FLCH_Active, bool) 0 == if{
                        (>K:AP_VS_HOLD_OFF) <!-- Turn Off VS Hold -->
                        (>K:PITCH_SYNC) <!-- Sync Pitch -->
                    }
                </Script>
            </MouseClick>
        </MouseArea>

        <!-- Update Logic -->
        <UpdateFrequency>6</UpdateFrequency>
        <Update>
            <Script>
                <!-- Only Adjust If FLCH is Active -->
                (L:FLCH_Active, bool) 1 == if{
                    <!-- Calculate Airspeed Difference -->
                    (A:AIRSPEED INDICATED, knots) (A:AUTOPILOT AIRSPEED HOLD VAR, knots) - (>L:FLCH_AirspeedDifference, number)

                    <!-- Scale the Difference -->
                    (L:FLCH_AirspeedDifference, number) 100 * (>L:VS_Adjustment, number)

                    <!-- Adjust VS Dynamically -->
                    (A:VERTICAL SPEED, feet per minute) (L:VS_Adjustment, number) + (>K:AP_VS_VAR_SET_ENGLISH)
                }
            </Script>
        </Update>
    </SimGauge.Gauge>
</SimBase.Document>
 
Curious that you can use the >, if I replaced it with &gt; I could drop this code right into 2020/2024. I'd have to futz with the mouse stuff a bit but ya. It's like everything is the same under the hood and they just changed the paint job.
 
Last edited:
Curious that you can use the >, if I replaced it with &gt; I could drop this code right into 2020/2024. I'd have to futz with the mouse stuff a bit but ya. It's like everything is the same under the hood and they just changed the paint job.
Don’t really need to though, MSFS developers were smart enough to put a default FLCH mode into their AP simulation. Don’t know why the previous MS sims never had it. X Plane has it by default also.
 
Back
Top