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

Help with Fuel Selector with AUX. in it

Messages
10,158
Country
us-arizona
Hey all,

This is for a XML parts code (ModelDef.xml) that would be a fuel selector, LBRAO (Left, Both, Right, Aux, Off).
The stock DC3 has two, which have A in the code, but it means 'All', not Aux.

Does anyone know how to code into the mix the AUX selection? This is the DC3 code;

Code:
    <!-- RLAO2 = Right/Left/All/Off #1.  They are different and used for DC3  -->
    <PartInfo>
        <Name>lever_fuel_selector_RLAO1</Name>
        <AnimLength>75</AnimLength>
        <Animation>
        <Parameter>
           <Code>3 3 3 1 2 2 0 7 (A:FUEL TANK SELECTOR:1, enum) case 25 *</Code>
           <Lag>100</Lag>
           </Parameter>
        </Animation>
        <MouseRect>
          <Cursor>Hand</Cursor>
          <HelpID>HELPID_GAUGE_FUEL_SELECTOR</HelpID>
          <TooltipID>TOOLTIPTEXT_DC3_LEFT_FUEL_SELECTOR</TooltipID>
          <MouseFlags>LeftSingle</MouseFlags>
             <CallbackCode>
         0 0 0 2 6 6 3 7 (A:FUEL TANK SELECTOR:1, enum) case (&gt;K:FUEL_SELECTOR_SET)
             </CallbackCode>
        </MouseRect>
    </PartInfo>


This is the standard, stock XML for LBRO...

Code:
    <PartInfo>
        <Name>switch_fuel_selector_LBRO</Name>
        <AnimLength>75</AnimLength>
        <Animation>
            <Parameter>
                <Code>2 0 1 3 1 5 (A:FUEL TANK SELECTOR:1, enum) ++ case 25 *</Code>
                <Lag>100</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <HelpID>HELPID_GAUGE_FUEL_SELECTOR</HelpID>
            <TooltipID>TOOLTIPTEXT_FUEL_SELECTOR</TooltipID>
            <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
            <CallbackCode>(M:Event) 'LeftSingle' scmp 0 ==
                if{ (M:X) (>G:Var1) 2 0 1 3 1 5 (A:FUEL TANK SELECTOR:1, enum) ++ case (>G:Var2) }
                els{ (M:X) (G:Var1) - 40 / int (G:Var2) + 0 max 3 min s0 2 0 1 3 1 5 (A:FUEL TANK SELECTOR:1, enum) ++ case !=
                    if{ l0 0 == if{ (>K:FUEL_SELECTOR_LEFT) } l0 1 == if{ (>K:FUEL_SELECTOR_ALL) } l0 2 == if{ (>K:FUEL_SELECTOR_RIGHT) } l0 3 == if{ (>K:FUEL_SELECTOR_OFF) } }</CallbackCode>
        </MouseRect>
    </PartInfo>


This is the core of the code above...

(M:Event) 'LeftSingle' scmp 0 ==
if{ (M:X) (>G:Var1) 2 0 1 3 1 5 (A:FUEL TANK SELECTOR:1, enum) ++ case (>G:Var2) }
els{ (M:X) (G:Var1) - 40 / int (G:Var2) + 0 max 3 min s0 2 0 1 3 1 5 (A:FUEL TANK SELECTOR:1, enum) ++ case !=
if{ l0 0 == if{ (>K:FUEL_SELECTOR_LEFT) } l0 1 == if{ (>K:FUEL_SELECTOR_ALL) } l0 2 == if{ (>K:FUEL_SELECTOR_RIGHT) } l0 3 == if{ (>K:FUEL_SELECTOR_OFF) } }

Could simply putting in a different set of codes take out 'all' and put in 'both' as well as adding AUX to the system?
Here, it is 2 0 1 3 1 5.


Many thanks for any help. Perhaps its already been covered in a post somewhere else. A link to it would be so much appreciated. I did some searches on this late last night with no joy.


Bill
LHC
 
Before posting any code for you it may be a good idea to paste the complete aircraft/sim.cfg [fuel] section.
Questions that need answering beforehand:
1) How many engines?
2) How many fuel selectors?
3) The big one... What "sim" tanks are assigned to the real "aircraft" tanks? IE An "aircraft" AUX tank could be any number of "sim" tanks - L AUX, R AUX, Center, Center1, Center2, Ext1, Ext2, R Tip & L Tip.
The confusion comes in where you are mentioning an AUX tank. There is no such thing. There is of course 2 auxiliary tanks - L AUX & R AUX.
So.. If the aircraft has only 1 AUX tank, which "sim" tank are you using for it?
The possible tanks available:
Code:
Fuel Tank Selection
Number    Description
0            Off
1            All
2            Left
3            Right
4            Left auxiliary
5            Right auxiliary
6            Center
7            Center2
8            Center3
9            External1
10            External2
11            Right tip
12            Left tip
13            Crossfeed
14            Crossfeed left to right
15            Crossfeed right to left
16            Both
17            External
18            Isolate
19            Left main
20            Right main
 
Here's one, fully tested using a single engine, single fuel selector & using the "center1" tank (aircraft.cfg) as the only Aux tank.
The Center1 was used because I believe, if for instance, the L.Aux was used as the only Aux then when the selector was in Left or Both the Aux tank would be used too. Using Center1 will aleve that.

XML:
<!-- For a 1 engine, 1 fuel selector aircraft using "Center1" as the SINGLE Aux tank -->
<!-- Selections/tanks used : 0 = Off, 2 = Left, 3 = Right, 6 = Center, 16 = Both (case indexed as 7 - "7 min") -->
<!-- 100 keyframes w/ positions on the "25's" -->


<PartInfo>
    <Name>LBRXO_Selector</Name>
    <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                <!-- Get things synched up if loaded from a saved flight where the saved flight uses an illegal tank = turn to BOTH -->
                (A:FUEL TANK SELECTOR:1, enum) sp26 7 15 l26 rng l26 16 &gt; l26 1 == l26 4 == l26 5 == or or or or if{ 16 (>K:FUEL_SELECTOR_SET) }   
                <!-- The actual animation -->
                 25 75 100 100 50 0 100 100 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case
                </Code>
                <Lag>100</Lag>
            </Parameter>
        </Animation>
    <MouseRect>
        <Cursor>Hand</Cursor>
        <TooltipText>Tank Selected = %((A:FUEL TANK SELECTOR:1, enum) 7 min)%{case}%{:0}OFF%{:1} %{:2}LEFT%{:3}RIGHT%{:4} %{:5} %{:6}AUX%{:7}BOTH%{end}%</TooltipText>
        <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
        <CallbackCode>
            (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == || if{ 2 3 0 0 16 2 0 6 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) }
            (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == || if{ 3 0 0 0 6 16 0 0 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) } 
        </CallbackCode>
    </MouseRect>
</PartInfo>
 
Last edited:
Many thanks, Roman.

I didnt think of that. Yep, Center1 tank. And a thousand thanks for the code. Off to check it out.

Bill
LHC
 
I seem to be having a problem. When I set it up per the notes on the code, the animation didnt match the commands. I reset movements per the mouserects, and then they were right except then it does a crazy jump in the selector animation, when going to AUX, it jumps straight to Off, skipping over it, and going under in the animation instead of over. If I add animation points to 'help it out', so it goes the correct direction, it stalls the animation. I guess it uses the points (number of points) on the KF ruler for stop points. So adding that crashes it.

I tried redoing the animation again. That did nothing. Same thing.

I am posting a photo of the selector. I think I know what the issue is. Its rotating more then 90 degrees without a KF reference point. It will go to the end point, but not Aux point. I guess its too far for it to travel without a KF point in there (more then 90deg). Its like that on tires and prop fans.

I wonder what I could do for a work around? I dont want to re-arrange the fonts as its important to stay authentic. A lot of Viking pilots will get this. I dont want it to be off.
2020-3-11_20-6-48-248.jpg
 
Ahh ok.. A picture tells a 1000 words. :cool:
New part name, describes operation from left to right. "XLBRO_Selector"
New keyframe amount (180) with the positions linear on their movement - 0 = AUX, 60 = LEFT, 90 = BOTH, 120 = RIGHT, 180 = OFF
The 3 lines that include the "case" selector determine the tank select logic & keyframe positions. What sim tank am I on now, on L or R click, where should I go? And, include the keyframe position based on the new tank selected.
Lines 16, 27 & 29, within the case arguments, needed to be changed to provide the logic in what the picture shows.

Hope this helps,
Roman
XML:
<!-- For a 1 engine, 1 fuel selector aircraft using "Center1" as the SINGLE Aux tank -->
<!-- Selections/tanks used : 0 = Off, 2 = Left, 3 = Right, 6 = Center, 16 = Both (case indexed as 7 - "7 min") -->
<!-- 180 keyframes: 0 = AUX, 60 = LEFT, 90 = BOTH, 120 = RIGHT, 180 = OFF  -->

<PartInfo>
    <Name>XLBRO_Selector</Name>
    <AnimLength>180</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                <!-- Get things synched up if loaded from a saved flight where the saved flight uses an illegal tank = turn to BOTH -->
                (A:FUEL TANK SELECTOR:1, enum) sp26 7 15 l26 rng l26 16 &gt; l26 1 == l26 4 == l26 5 == or or or or if{ 16 (>K:FUEL_SELECTOR_SET) }  
                <!-- The actual animation -->
       <!-- Index 7 6 5 4   3  2 1   0 -->
                 90 0 0 0 120 60 0 180 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case
                </Code>
                <Lag>100</Lag>
            </Parameter>
        </Animation>
    <MouseRect>
        <Cursor>Hand</Cursor>
        <TooltipText>Tank Selected = %((A:FUEL TANK SELECTOR:1, enum) 7 min)%{case}%{:0}OFF%{:1} %{:2}LEFT%{:3}RIGHT%{:4} %{:5} %{:6}AUX%{:7}BOTH%{end}%</TooltipText>
        <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
        <CallbackCode>
            <!-- OFF, RIGHT, BOTH, LEFT, AUX -->                         <!-- Index 7 6 5 4  3 2 1 0 -->
            (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or if{ 2 6 0 0 16 6 0 3 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) }
            <!-- AUX, LEFT, BOTH, RIGHT, OFF -->                        <!-- Index 7 6 5 4 3  2 1 0 -->
            (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or if{ 3 2 0 0 0 16 0 0 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) }
        </CallbackCode>
    </MouseRect>
</PartInfo>
 
Last edited:
GOODNESS!!!!!!!!!!

GOD BLESS YOU, Roman!

Worked Perfect...

For the sake of figuring this out... What is the number 8 in this system? I noticed you left that out of the Legend in the code;

Code:
            <!-- OFF, RIGHT, BOTH, LEFT, AUX -->                         <!-- Index 7 6 5 4  3 2 1 0 -->
            (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or if{ 2 6 0 0 16 6 0 3 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) }
            <!-- AUX, LEFT, BOTH, RIGHT, OFF -->                        <!-- Index 7 6 5 4 3  2 1 0 -->
            (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or if{ 3 2 0 0 0 16 0 0 8 (A:FUEL TANK SELECTOR:1, enum) 7 min case (>K:FUEL_SELECTOR_SET) }

7 6 5 4 3 2 1 0 <-- I do not understand what this is. There are 5 selections on the selector. Why 7 and why backwards? Is it an index thing for fuel only?
2 6 0 0 16 6 0 3 8

7 6 5 4 3 2 1 0
3 2 0 0 0 16 0 0 8


NOTES FROM SDK:
(For others looking at this post down the road in the future).
Fuel selector codes///////////////////////////////////

FUEL_TANK_SELECTOR_OFF = 0
FUEL_TANK_SELECTOR_ALL = 1
FUEL_TANK_SELECTOR_LEFT = 2
FUEL_TANK_SELECTOR_RIGHT = 3
FUEL_TANK_SELECTOR_LEFT_AUX = 4
FUEL_TANK_SELECTOR_RIGHT_AUX = 5
FUEL_TANK_SELECTOR_CENTER = 6
FUEL_TANK_SELECTOR_CENTER2 = 7
FUEL_TANK_SELECTOR_CENTER3 = 8
FUEL_TANK_SELECTOR_EXTERNAL1 = 9
FUEL_TANK_SELECTOR_EXTERNAL2 = 10
FUEL_TANK_SELECTOR_RIGHT_TIP = 11
FUEL_TANK_SELECTOR_LEFT_TIP = 12
FUEL_TANK_SELECTOR_CROSSFEED = 13
FUEL_TANK_SELECTOR_CROSSFEED_L2R = 14
FUEL_TANK_SELECTOR_CROSSFEED_R2L = 15
FUEL_TANK_SELECTOR_BOTH = 16
FUEL_TANK_SELECTOR_EXTERNAL_ALL = 17
FUEL_TANK_SELECTOR_ISOLATE = 18

Codes for Tanks on this plane would be;
6 2 16 3 0 which is Aux Left Both Right Off, and vice versa for right click.

The codes you have for this selector;
2 6 0 0 16 6 0 3 8

What are the zeros? What is the 8?
 
Bill..
Happy it worked for you!
Hope this helps in explaining the very powerful & useful "case" evaluation.

case.png


If not, another description is available here, in the P3D SDK. Scroll down to "special operators".

"Indexes" are zero based, right to left, and you cannot skip an index value.
Indexes & tanks 1 (all), 4 (l aux) & 5 (r aux) are not used at all, will never get selected, therefore, a 0 is in its place to keep the indexing in a contiguous sequence. When writing the code I put X's in those indexes to keep the confusion down until absolutely sure the logic ended up correct, then replaced with zeroes. That is also why I put the comments of the index numbers above the code - to keep sanity!
This code is not generic at all. Built specifically for the type of selector in your project. I could of put every single tank in the index selection but it gets overly complicated then. ( as if it wasn't enough already :rotfl: )
For example, you are using tank selections 0, 2, 3, 6 & 16. A semi-contiguous range of 0 thru 6. So to keep the code a little less verbose, writing all selections up to and including 16, I assigned tank selection 16 to index 7, the next available index.
The code to do that was nothing more than - " 7 min " If the value is greater than 7, return a 7.

As I mentioned before - very powerful & useful.. It can be also extremely confusing!
Here's an example from a radar scope where 28 different colors are used for brightness/contrast adjustments but can be different in 3 operational modes - 84 selections.
XML:
... Stuff

    <Macro Name="COLOR">
      <MacroValue>%('0xffffff' '0xfcfffc' '0xeaffea' '0xd8ffd8' '0xc6ffc6' '0xb4ffb4' '0xa2ffa2' '0x90ff90' '0x7eff7e' '0x6cff6c' '0x5aff5a' '0x48ff48' '0x36ff36' '0x24ff24' '0x12ff12' '0x00ff00' '0x00ea00' '0x00d800' '0x00c600' '0x00b400' '0x00a200' '0x009000' '0x007e00' '0x006c00' '0x005a00' '0x004800' '0x003600' '0x002400' 28 @1 case)</MacroValue>
    </Macro>
    <Macro Name="CURSOR_VC_E">
      <MacroValue>L:TFR_CURS_VC_E,number</MacroValue>
    </Macro>
    <Macro Name="CURSOR_VC_GM">
      <MacroValue>L:TFR_CURS_VC_GM,number</MacroValue>
    </Macro>
    <Macro Name="CURSOR_VC_SIT">
      <MacroValue>L:TFR_CURS_VC_SIT,number</MacroValue>
    </Macro>
    <Macro Name="COLOR_PICKER_CURS">
      <MacroValue>(@CURSOR_VC_E) (@CURSOR_VC_GM) (@CURSOR_VC_SIT) 3 (L:ColorType_VC, number) case</MacroValue>
    </Macro>

... More Stuff

          <Element>
            <FloatPosition>0.000,19.000</FloatPosition>
            <Visibility>(P:Absolute time,seconds) 0.5 % 0.4 1 * > ! l5 145 &lt; and</Visibility>
            <VerticalLine>
              <Bright>True</Bright>
              <Height>5</Height>
              <LineWidth>1</LineWidth>
              <LineColor>@COLOR(@COLOR_PICKER_CURS)</LineColor>
            </VerticalLine>
          </Element>

Here are 2 more tank selections you can add to your list.. Very deeply hidden in the SDK, but available.
FUEL_TANK_SELECTOR_LEFT_MAIN = 19
FUEL_TANK_SELECTOR_RIGHT_MAIN = 20
Note - These are different than selections 2 & 3.. 19 & 20 will use those tanks and those tanks only. Whereas 2 & 3 will use some built in logic to them. Burn from tip then aux then main.

EDIT - There are many more ways this could've been done. Here's another example, using more expressions to "fit" all the selections into each of the indexes :
XML:
<!-- EXAMPLE, FOR LEFT CLICK
INDEX/SELECTOR - 0/0 = OFF
INDEX/SELECTOR - 1/16 = BOTH
INDEX/SELECTOR - 2/2 = LEFT
INDEX/SELECTOR - 3/3 = RIGHT
INDEX/SELECTOR - 4/6 = AUX
-->

if{ 6 16 6 2 3 5 (A:FUEL TANK SELECTOR:1, enum) s25 6 == if{ 4 } els{ l25 16 == if{ 1 } els{ l25 } } case (>K:FUEL_SELECTOR_SET) }
 
Last edited:
many thanks roman, I just understand what was that number from long time ago when start learning SDK and modeldef.xml. one of the reason moving to C++, cause not understand that things
 
A thousand thanks Roman for the lesson on this.

It always kind of confuses me how the code can be understood by the simulator. To me, it looks like it cannot, absolutely cannot work. But it does...

I tried writing my own code for landing gear for a light to show up when the gear system is 'in transition'. I just couldnt get it to work, so I used an ancient code in one of my older planes to get it to work. It has modernized heiroglyphs in some techno algebraic OS to explain how the red light should come on. Works excellent... But how, is a complete mystery...


Code:
  <PartInfo>
    <Name>lhc_lit_gear_transition</Name>
    <Visibility>
      <Parameter>
        <Code>
(A:gear left position,percent) d (G:Var1) - r (&gt;G:Var1) 0 != 4 * (G:Var2) max -- 0 max d (&gt;G:Var2) 0 !=
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
Bill,
You are welcome sir.
It has modernized heiroglyphs in some techno algebraic OS to explain how the red light should come on. Works excellent... But how, is a complete mystery...
Tried over and over again to figure that one out.. No idea whatsoever! But hey.. if it works.
Here's one..
It is simple. If the gear is between 0.01% and 99.99% it means it is between full up and full down, IE in transit.
XML:
  <PartInfo>
    <Name>gear_transition_example</Name>
    <Visibility>
      <Parameter>
        <Code>
0.01 99.99 (A:gear left position,percent) rng
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
Last edited:
I'm jumping in the stress this comment from Roman:

Burn from tip then aux then main.

Do not use Main if you want full control of your tanks. Use External, Aux, Tip and CenterX only.
 
I use main without issue... why would you not use main? The main tank works fine... it's the external aux and tip that we have no control over.
 
I walked into that..! Yes, as Ed rightly says, main on its own is okay (LeftMain and RightMain - selectors 19 and 20). I'm using main, tip and centerX on the current project and they're all independently controlled. It's selectors 2 & 3 that will burn tip-aux-main. Yet again I tender an apology for making a statement without providing the required detail to flesh it out (Gotta get out of that damn habit).
 
Last edited:
Everything I mentioned above is true.
It all comes down to what kind of fuel system logic you want (in the real aircraft) & what fuel tanks you have assigned in the aircraft.cfg.
Of course, if one doesn't have the tank assigned in the aircraft.cfg, any built in logic that includes the tank doesn't exist.
There's a bit more involved and some quirky tank selections from built in logic behind them.
Attached is a test gauge to see for yourself.
screenshot.png
 

Attachments

my Tu144 use all internal tank variable (if it available more, I'll use it too), with 2 option fuel system: manual and semi automatic.
 
Back
Top