• 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 Consumed Fuel counter

Messages
59
Country
france
I try to create a counter Kent which measures the amount of fuel consumed by the engine.

For this I need:
  1. keep the initial amount of fuel in the tanks,
  2. store this information
  3. subtract the amount of remaining fuel at time "T"
So consumption displayed = initial amount - remaining amount .

To store the initial amount, I thought to use "s0" / "l0", but I do not know how to use it in my code.

<PartInfo>
<Name>00-NORD_Fuel_Gauche_Total</Name>
<Visibility>
<Parameter>
<Code>

(A:FUEL TANK LEFT MAIN QUANTITY, liters) (A:FUEL TANK LEFT AUX QUANTITY, liters) + (A:FUEL TANK CENTER QUANTITY, liters) + (&gt;L:Fuel_Total_Gauche_Initial, liters) s0

(A:FUEL TANK LEFT MAIN QUANTITY, liters) (A:FUEL TANK LEFT AUX QUANTITY, liters) + (A:FUEL TANK CENTER QUANTITY, liters) + (&gt;L:Fuel_Total_Gauche_Courant, liters)

l0 (L:Fuel_Total_Gauche_Courant, liters) - (&gt;L:Fuel_Total_Gauche_Consomme, liters)

</Code>
</Parameter>
</Visibility>
</PartInfo>


This code doesn't work and I find the same values ​​for the three variables.
for example:

L: Fuel_Total_Gauche_Initial, liters => 210
L: Fuel_Total_Gauche_Courant, liters => 210
L: Fuel_Total_Gauche_Consomme, liters => - 210

In my opinion, I need help.

Thank you in advance
 
Last edited:
All of your A:Variables are invalid.
Look up the simulation variables section in the SDK to get working A:Vars.
 
What are Visibility and /Visibility doing in there?

Your s0 and l0 are essentially doing nothing - it is just storing the value and then popping that value off the stack, every gauge cycle. You are *not* storing it unchanged.

Your "initial" variable is constantly changing as the fuel amount goes down - you need to set a trigger for that condition so it only gets set once, then never changes again. Perhaps a reset button on the panel, or the engines starting up - that kind of thing.

Hope this helps,
 
Tom, any script in a <PartInfo> definition with a <Visibility> tag and which is assigned to a small polygon in a compiled model will function as a "gauge" that's continuously executed each sim cycle.

It's a trick I discovered and reported about several years ago.

I do agree however that the first calculation need only be done once, and hence should be wrapped in an initialization routine:

Code:
<Visibility>
    (L:Init,bool) 0 ==
    if{
          (* one-time calculations go here *)
          1 (>L:Init,bool)
      }

    (* rest of XML script goes here *)

</Visibility>

Instead of using a stack variable to store the results of the total fuel calculation however, an (L:Var,units) should be used. This is because a stack variable cannot be used anywhere else in the panel/gauge system, but is local to the XML script in which it is used.
 
Last edited:
I'm a fan of the "small polygon"

Here is my code for the polygon :

<PartInfo>
<Name>00-NORD_Fuel_Gauche_Total</Name>
<Visibility>
<Parameter>
<Code>
(L:Init_Fuel_Gauche,bool) 0 == if{ (A:FUEL TANK LEFT MAIN QUANTITY, liters) (A:FUEL TANK LEFT AUX QUANTITY, liters) + (A:FUEL TANK CENTER QUANTITY, liters) + (&gt;L:Fuel_Total_Gauche_Initial, liters) 1 (&gt;L:Init_Fuel_Gauche,bool) }

(A:FUEL TANK LEFT MAIN QUANTITY, liters) (A:FUEL TANK LEFT AUX QUANTITY, liters) + (A:FUEL TANK CENTER QUANTITY, liters) + (&gt;L:Fuel_Total_Gauche_Courant, liters)

(L:Fuel_Total_Gauche_Initial, liters) (L:Fuel_Total_Gauche_Courant, liters) - (&gt;L:Fuel_Total_Gauche_Consomme, liters)
</Code>
</Parameter>
</Visibility>
</PartInfo>


And for the animated reset :

<PartInfo>
<Name>00-NORD_Fuel_Gauche_Total_Reset</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:Fuel_Total_Gauche_Reset,number) 100 *
</Code>
<Lag>400</Lag>
</Parameter>
</Animation>

<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Reset Reservoirs Gauche</TooltipText>
<CallbackCode>
(L:Fuel_Total_Gauche_Reset,number) ! (&gt;L:Fuel_Total_Gauche_Reset,number)
(L:Fuel_Total_Gauche_Reset,number) 1 == if{ 0 (&gt;L:Init_Fuel_Gauche,bool) }
</CallbackCode>
</MouseRect>
</PartInfo>


That works perfectly. Thank you.

I hope this will help someone
 
Great! I'm a "fan" of using the bloody
Code:
 wrapper in this forum, as well as line spacing and indents to make XML scripts easier to read! :D

[CODE]
<PartInfo>
  <Name>00-NORD_Fuel_Gauche_Total</Name>
  <Visibility>
    <Parameter>
      <Code>
        (L:Init_Fuel_Gauche,bool) 0 == 
          if{ 
            (A:FUEL TANK LEFT MAIN QUANTITY, liters) 
            (A:FUEL TANK LEFT AUX QUANTITY, liters) + 
            (A:FUEL TANK CENTER QUANTITY, liters) + 
            (&gt;L:Fuel_Total_Gauche_Initial, liters) 
            1 (&gt;L:Init_Fuel_Gauche,bool) 
            }

        (A:FUEL TANK LEFT MAIN QUANTITY, liters) 
        (A:FUEL TANK LEFT AUX QUANTITY, liters) + 
        (A:FUEL TANK CENTER QUANTITY, liters) + 
        (&gt;L:Fuel_Total_Gauche_Courant, liters)

        (L:Fuel_Total_Gauche_Initial, liters) 
        (L:Fuel_Total_Gauche_Courant, liters) - 
        (&gt;L:Fuel_Total_Gauche_Consomme, liters)
      </Code>
    </Parameter>
  </Visibility>
</PartInfo>

I really dislike the practice of using "run on sentences" when creating/posting XML scripts!
 
:(:(:banghead:

Code:
<Sorry>

	I'll never again !
	I had not found the right button ! 

</Sorry>

Well, it won't work with that logic error since the ! will reverse the result.
So you will actually do it again and you will find the right button, what somehow throws you into a weird loop.:D
 
Back
Top