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

Some help with Fuel Selector bug

Messages
58
So I have a simple fuel selector gauge animated and coded along with a visual tag to initiate the selector but keep seeing this bug.

The fuel draw upon loading the aircraft always comes from my center 2 tank regardless of the position of the selector. Only after I mouse click and change selector position does the draw come from the appropriate tank. There are only 3 positions (OFF, Center 2, Center 1). Also upon loading the aircraft, fuel will continue to draw from Center 2 until empty and then begin drawing from Center 1 instead of cutting off. Turning the switch remedies this and the switch works as designed but not sure why this happens to a a newly loaded aircraft with a fuel selector untouched.

Below is my code. and Center1 and Center2 tanks are defined in the .cfg

Any help greatly appreciated

Code:
    <PartInfo>
    <Name>aircraft_initialize_fuel</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:myplane_init, bool) 0 ==
          if{
            0 (>L:fuel switch, enum)
            1 (>L:myplane_init, bool)
           and }
        </Code>
      </Parameter>
    </Visibility>
    </PartInfo>
    <PartInfo>
    <Name>aircraft_fuel_selector</Name>
    <AnimLength>120</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:fuel switch, enum) 60 *</Code>
        <Lag>100</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <MouseFlags>WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'WheelUp' scmp 0 == if{ (L:fuel switch, enum) ++ 2 min (>L:fuel switch, enum) }
        (M:Event) 'WheelDown' scmp 0 == if{ (L:fuel switch, enum) -- 0 max (>L:fuel switch, enum) }

        (L:fuel switch, enum) 0 == if{ 0 (>K:FUEL_SELECTOR_SET) }
        (L:fuel switch, enum) 1 == if{ 7 (>K:FUEL_SELECTOR_SET) }
        (L:fuel switch, enum) 2 == if{ 6 (>K:FUEL_SELECTOR_SET) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Messages
440
Country
us-wisconsin
Most likely because in your ini section the L:Var is set but the selector is not.
The coding for the actual selector only occurs once clicked, IE the callback section.
Maybe give this a try for the "aircraft_initialize_fuel" part.
This will result in the aircraft being loaded with the fuel selector off.

XML:
<PartInfo>
<Name>aircraft_initialize_fuel</Name>
    <Visibility>
        <Parameter>
            <Code>
                (L:myplane_init, bool) 0 ==
                if{
                0 (>L:fuel switch, enum)
                0 (>K:FUEL_SELECTOR_SET)
                1 (>L:myplane_init, bool)
                }
            </Code>
        </Parameter>
    </Visibility>
</PartInfo>

Roman
 
Messages
58
Thanks Roman for the reply. I tried your code but no luck. The Selector and LVAR are both set to Off but upon startup, engine is always on and and draws from Center2. I did attempt to load the aircraft from the select aircraft menu dropdown and all seems to be working as intended, just not when loading from initial selection screen.
 

tgibson

Resource contributor
Messages
11,338
Country
us-california
You are then loading from a flight, which sets the fuel selector to the value coded in the Flight. You could try putting Romans's code into a gauge listed in the VC section of the panel.cfg file - perhaps that loads after the Flight? Not sure.
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
You could set the sim's fuel selector in your animation code, rather than the callback. Also, maybe the use of &gt; instead of > might help.

Code:
    <PartInfo>
    <Name>aircraft_fuel_selector</Name>
    <AnimLength>120</AnimLength>
    <Animation>
      <Parameter>
        <Code>
            (L:fuel switch, enum) 0 == if{ 0 (&gt;K:FUEL_SELECTOR_SET) }
            (L:fuel switch, enum) 1 == if{ 7 (&gt;K:FUEL_SELECTOR_SET) }
            (L:fuel switch, enum) 2 == if{ 6 (&gt;K:FUEL_SELECTOR_SET) }
            
            (L:fuel switch, enum) 60 *
        </Code>
        <Lag>100</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <MouseFlags>WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'WheelUp' scmp 0 == if{ (L:fuel switch, enum) ++ 2 min (&gt;L:fuel switch, enum) }
        (M:Event) 'WheelDown' scmp 0 == if{ (L:fuel switch, enum) -- 0 max (&gt;L:fuel switch, enum) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Maybe one more thing: I'm not quite sure why you're using a visibility code section for your initialization? You could add the initialization to the Animation code as well, but I think the more elegant solution is to create a XML gauge with either an update section (FSX/P3D) or element (FS9) in which you use your initialization code. This way, you can have all your initializations in one place and don't get confused with your various (L:myplane_init, bool) variables you'd otherwise have to keep track of.
 
Messages
58
You could set the sim's fuel selector in your animation code, rather than the callback. Also, maybe the use of &gt; instead of > might help.

Code:
    <PartInfo>
    <Name>aircraft_fuel_selector</Name>
    <AnimLength>120</AnimLength>
    <Animation>
      <Parameter>
        <Code>
            (L:fuel switch, enum) 0 == if{ 0 (&gt;K:FUEL_SELECTOR_SET) }
            (L:fuel switch, enum) 1 == if{ 7 (&gt;K:FUEL_SELECTOR_SET) }
            (L:fuel switch, enum) 2 == if{ 6 (&gt;K:FUEL_SELECTOR_SET) }
           
            (L:fuel switch, enum) 60 *
        </Code>
        <Lag>100</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <MouseFlags>WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'WheelUp' scmp 0 == if{ (L:fuel switch, enum) ++ 2 min (&gt;L:fuel switch, enum) }
        (M:Event) 'WheelDown' scmp 0 == if{ (L:fuel switch, enum) -- 0 max (&gt;L:fuel switch, enum) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

That did the trick Vitus... Many thanks!
 
Messages
440
Country
us-wisconsin
One thing about Vitus' code..
It probably will cause "constant firing" of the FUEL_SELECTOR_SET command.
Being in the model code this will occur at the sim frame rate.
IMO a no-no, specially if used in a multiplayer environment. But... a lot of quality payware designers are doing it. :eek::spam:
The following should prevent this..
XML:
<Code>
    (L:fuel switch, enum) 0 == (A:FUEL TANK SELECTOR 1, enum) 0 != and if{ 0 (&gt;K:FUEL_SELECTOR_SET) }
    (L:fuel switch, enum) 1 == (A:FUEL TANK SELECTOR 1, enum) 7 != and if{ 7 (&gt;K:FUEL_SELECTOR_SET) }
    (L:fuel switch, enum) 2 == (A:FUEL TANK SELECTOR 1, enum) 6 != and if{ 6 (&gt;K:FUEL_SELECTOR_SET) }

    (L:fuel switch, enum) 60 *
</Code>
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
That's actually a really good point! Your solution is elegant. :wizard:
 
Messages
58
After some further tinkering, looks like what was causing my bug was that my two mdl files were not using the same code. I was only updating my interior model while the exterior model was from a previous compile.

Thanks all for all the great feedback
 
Top