#Found code for custom variable but not sure what part
1 messages · Page 1 of 1 (latest)
I am flying the f22 on msfs2020 I tried 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 l0 * + 100 * (>K:2:AP_MACH_VAR_SET) and 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 l0 * + 0 max (>K:2:AP_SPD_VAR_SET) but all I could do is the first one worked but it only worked one time and it would decrease
You need to learn the RPN syntax and functions
For example l0 is load value stored in register 0 to stack, but you can't load something if you didn't save it with p0 or s0 first.
In this case, the value being stored is +1 or -1 to be used as multiplier in the code to increase or decrease the value to be set.
You don't need the multiplier because you know which event (Inc or Dec) you are dealing with so you know which sign to use.
thank you, could I have some more information?
For INC
(L:XMLVAR_AirSpeedIsInMach) if{ 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 + 100 * (>K:2:AP_MACH_VAR_SET) } els{ 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 + 0 max (>K:2:AP_SPD_VAR_SET) }
For DEC
(L:XMLVAR_AirSpeedIsInMach) if{ 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 - 100 * (>K:2:AP_MACH_VAR_SET) } els{ 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 - 0 max (>K:2:AP_SPD_VAR_SET) }
It worked. Thank you!
But please note the only difference between the two events is just the + or - sign. That is what I meant by not needing the multiplier.