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

FSXA Please explain

Messages
189
Country
hungary
Hello !

I want to use this code from the SDK to select tanks : lever_fuel_selector_LBRO, but with modification to OLRB. The knob animated to 75 frames :

0 = Off
25 = Left
50 = Right
75 = Both

Can somebody explain the logic of the code ? I WANT to understand it first, after that I will modify it :)

Code:
<PartInfo>
    <Name>lever_fuel_selector_LBRO</Name>
    <AnimLength>75</AnimLength>
    <Animation>
      <Parameter>
        <Code>0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 3 21 (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</MouseFlags>
      <CallbackCode>
        0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 16 0 2 3 21 (A:FUEL TANK SELECTOR:1, enum) case (&gt;K:FUEL_SELECTOR_SET)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
I throughly despise that "case" type script. It's a major PITA to work with.

I much prefer a simpler, kinder approach such as this example.

It's straight forward, using a custom L:var to mouse between 0 and 3 for a total of four positions. The mouse script will "set" the tank selector for engine 1 according to the table from the FSX SDK (see below).

The animation code will multiply the L:var by a scalar of 25 to produce the keyframes you outlined in your post.

It will default to the "Left" tank as scripted, but it's easy enough to offset the 0 frame to "Both" by changing the min max values, and adding a bias value in the animation.

Code:
<PartInfo>
  <Name>OLRB_FuelSel</Name>
  <AnimLength>75</AnimLength>
  <Animation>
    <Parameter>
      <Code>
        (L:FuelKnob,enum) 25 *
      </Code>
      <Lag>100</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Fuel Selector</TooltipText>
    <MouseFlags>LeftSingle+RightSingle+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == and
      if{ (L:FuelKnob, enum) -- 0 max (>L:FuelKnob, enum) }
      
      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == and
      if{ (L:FuelKnob, enum) ++ 3 min (>L:FuelKnob, enum) }
      
      (L:FuelKnob,enum) 0 == if{ 0 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 1 == if{ 2 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 2 == if{ 3 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 3 == if{ 16 (&gt;K:FUEL_SELECTOR_SET) }
    </CallbackCode>
  </MouseRect>
</PartInfo>

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
 
Thank you ! You're right, this code is more easier to understand also :) There is only one thing I have to solve : the knob itself not animating in FS...
 
Also... A small bug of sorts. When you first start your plane, the tanks will be on 'all' selection. Also, it seems the knob will be in forward position (at least for me) on these custom selectors. Its a core sim issue. An invisble gauge code might be able to set this correct.
 
Thank you ! You're right, this code is more easier to understand also :) There is only one thing I have to solve : the knob itself not animating in FS...

You did create an <Animation ... GUID= .../> entry for it, correct?

You animate the knob from frame 0 to frame 75, with keys at 0, 25, 50, 75...
 
You also made sure that your "typeParam2" entry is the same as the animation name?
 
Ok, now the anim is working. I don't know what was wrong, but it is over now :)

But the operation of the knob isn't good for me. I use BlackBox to show variables, so I can check if my instruments,gauges,knobs,switches shows the correct value or not. When I first load the plane, the state is the following :

- fuel selector is in OFF position
- variable of the fuel selector is 1 = All, (A:FUEL TANK SELECTOR:1, enum)
- engine stopped, but startable

From this state :

- to left mouse click : the variable of fuel selector changes to 0, without animating the knob, because it is in the OFF position already
- to right mouse click : the variable of fuel selector changes to 2, with animating the knob.

Which parameter sets the default position of the knob?
 
As the other Bill (Lionheart) said, by default the sim always has the tank(s) set to BOTH.

So, let us write a little bit of script that will pre-set your L:variable to the BOTH position...

What this should do is check to see if (L:FuelKnobInit,bool) has been set yet. If not, then set the (L:FuelKnob,enum) variable to 3 (which is BOTH position), then set the check variable to 1 so it won't be run again.

Code:
<PartInfo>
  <Name>OLRB_FuelSel</Name>
  <AnimLength>75</AnimLength>
  <Animation>
    <Parameter>
      <Code>
        (L:FuelKnobInit,bool) 0 ==
        if{
            3 (>L:FuelKnob,enum)
            1 (>L:FuelKnobInit,bool)
          }
        (L:FuelKnob,enum) 25 *
      </Code>
      <Lag>100</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Fuel Selector</TooltipText>
    <MouseFlags>LeftSingle+RightSingle+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == and
      if{ (L:FuelKnob, enum) -- -3 max (>L:FuelKnob, enum) }
      
      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == and
      if{ (L:FuelKnob, enum) ++ 0 min (>L:FuelKnob, enum) }
      
      (L:FuelKnob,enum) 0 == if{ 0 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 1 == if{ 2 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 2 == if{ 3 (&gt;K:FUEL_SELECTOR_SET) }
      (L:FuelKnob,enum) 3 == if{ 16 (&gt;K:FUEL_SELECTOR_SET) }
    </CallbackCode>
  </MouseRect>
</PartInfo>
 
Thank you Bill ! I need the OFF position to default. I put this :

Code:
(L:FuelKnobInit,bool) 0 ==
        if{
            0 (>L:FuelKnob,enum)
            1 (>L:FuelKnobInit,bool)
          }

but everything is the same like I wrote in my last post.
 
Thank you Bill ! I need the OFF position to default. I put this :

Code:
(L:FuelKnobInit,bool) 0 ==
        if{
            0 (>L:FuelKnob,enum)
            1 (>L:FuelKnobInit,bool)
          }

but everything is the same like I wrote in my last post.

I thought you wanted the 3d knob to match the sim's tank selection. Since all L:vars automatically initialize to 0, the script above is actually doing NOTHING at all!

If you want to force the sim's tank selection when you load the aircraft, then rewrite the script to this:

Code:
(L:FuelKnobInit,bool) 0 ==
        if{
            0 (&gt;K:FUEL_SELECTOR_SET)
            1 (>L:FuelKnobInit,bool)
          }
The above should force the sim's tank selection from "ALL" to "OFF."
 
Just a side comment: if there is only two fuel tanks, selecting ALL would be the same as selecting BOTH, and the script to handle its operation could be improved a bit.

Tom
 
The plane has two fuel tanks in each wing : one in the wingtip (left and right aux), one in the wing (left and right main). The arrows show the filler caps. The fuel flows from the wingtip tanks to the main tanks by gravity, because the wing has a relatively high dihedral (approx. 6 degrees). There is also a center tank on the lowest point before the engine get the fuel, which is a collector for all tanks, but I won't modeling it.

142%2520tank.JPG


The fuel knob in the off ( 0 ) position :

142%2520tank2.JPG


The pilot has to set the knob into the yellow mark, which selects the left tank(s). He has to use this tank first, and when it's run out from fuel, he must select the right tank(s).
 
The simplest way to handle that system is to just use 2 main tanks in the aircraft.cfg file. That way the fuel all drains from the tank to the engine (just as it does in your setup). If there are separate fuel gauges for each of the 4 tanks, then you can set that up in your gauge code.

An example - 50 gallons in the AUX tank and 100 gallons in the MAIN tank. Set up MAIN tanks in the cfg file with 150 gallons each.

150 to 100 gallons - the needle of the AUX tank gauge goes from full to empty, MAIN tank gauge stays at full.

100 to 0 gallons - the needle of the MAIN tank gauge goes from full to empty, AUX tank gauge stays at empty.

Hope this helps,
 
The simplest way to handle that system is to just use 2 main tanks in the aircraft.cfg file. That way the fuel all drains from the tank to the engine (just as it does in your setup). If there are separate fuel gauges for each of the 4 tanks, then you can set that up in your gauge code.

An example - 50 gallons in the AUX tank and 100 gallons in the MAIN tank. Set up MAIN tanks in the cfg file with 150 gallons each.

150 to 100 gallons - the needle of the AUX tank gauge goes from full to empty, MAIN tank gauge stays at full.

100 to 0 gallons - the needle of the MAIN tank gauge goes from full to empty, AUX tank gauge stays at empty.

Hope this helps,


Thanks ! That's a very good idea ! Why couldn't I invent this?! :D
 
The big advantage about using Tom's method is that you have automated the fuel flow, so the engine will not run out of fuel and stop when you least expect it.

Another advantage is that you will not have to cope with the excessive roll FS creates if the left wing fuel weight is different from the right wing fuel weight.

Of course, you still have to work out how to automate the fuel knob position.

Roy
 
The big advantage about using Tom's method
...

Actually I guess it's the only method possible as surely is the same used by the real aircraft. The fuel tank selector has only left and right positions, which means a single tank is considered for each wing. I guess too that it has only one fuel qty gauge per wing (left-right), including both the main and wing tip tanks.
Having a collector tank in the belly means also the normal operating position for the fuel selector should be in the BOTH detent, so that fuel would be consumed from both tanks proportionaly, avoiding the wing roll that Roy mentions.

Tom
 
Actually I guess it's the only method possible as surely is the same used by the real aircraft. The fuel tank selector has only left and right positions, which means a single tank is considered for each wing. I guess too that it has only one fuel qty gauge per wing (left-right), including both the main and wing tip tanks.
Having a collector tank in the belly means also the normal operating position for the fuel selector should be in the BOTH detent, so that fuel would be consumed from both tanks proportionaly, avoiding the wing roll that Roy mentions.

Tom

The plane has four tank qty gauge ! Each tank in the wing has its own level sensor.
 
Back
Top