Put the timer aside for now.
Here's the macro section that belongs to the bar's code posted above:
Code:
<!--
Macro PayloadBox[n]_Index - Is the payload station index as specified in the aircraft.cfg or FSX load manager (start count at 1)
Macro PayloadBox[n]_Limit - Is the payload station weight limit in lbs (1 lbs = 0.453592 kg)
Macro PayloadBox[n]_X - X axis position of payload station box in the aircraft manager window
Macro PayloadBox[n]_Y - Y axis position of payload station box in the aircraft manager window
Macro PayloadBox[n]_W - Width of the payload station box
Macro PayloadBox[n]_H - Height of the payload station box
-->
<Macro Name="PayloadBox9_Index">9</Macro>
<Macro Name="PayloadBox9_Limit">3300</Macro>
<Macro Name="PayloadBox9_X">200</Macro><Macro Name="PayloadBox9_Y">470</Macro>
<Macro Name="PayloadBox9_W">40</Macro><Macro Name="PayloadBox9_H">80</Macro>
<!-- FRAME COLOR of the payload/fuel station boxes -->
<Macro Name="StnBoxFrmClr">#fafafa</Macro>
<!-- FILL COLOR of the payload/fuel/door station boxes -->
<Macro Name="StnBoxFillClr">#747474</Macro>
<!-- BAR COLOR of the payload/fuel station boxes -->
<Macro Name="StnBoxBarClr">darkgreen</Macro>
Macros provide an easy way to avoid having to write repetitive code. The gauge parser stores the names and the associated values of the macros in memory and when it encounters references to said names (the "@..." thingys) in the remainder of the gauge script, it will assign the values it has stored for those names. "Height=@PayloadBox9_H" will therefor turn into "Height=80". Like variables in algebra.
Replace all the "@..." macro references in my above script with the associated value from the macro section and you will see what I mean.
The equation to shift the Y position of the top left corner of the rectangle that is used to fill the bar is necessary because gauge rectangles are always drawn from the top left. Good for horizontal bars, bad for vertical bars that are supposed to fill from the bottom. If you look closely, the equation is duplicated to specify the height of the rectangle itself as well.
This is the equation driving the origin and height of the bar graph:
Code:
(A:PAYLOAD STATION WEIGHT:@PayloadBox9_Index, pounds) @PayloadBox9_H @PayloadBox9_Limit / * @PayloadBox9_H min
With the numbers from the macros filled in:
Code:
(A:PAYLOAD STATION WEIGHT:9, pounds) 80 3300 / * 80 min
The frame of the bar graph indicating the payload station's weight has a fixed height of 80 pixel, but the payload station can take any value, i.e. weight that I want. So without that equation, any station weight greater than 80 lbs would make the bar grow beyond its frame.
Since this would look awfully dumb, I need something to limit the bar, therefor I assign a maximum value to the station, in this case 3300 lbs*. However, 3300 lbs is still way too high a number for the frame. So therefor, I need a scale value to slow the bar's height growth and to ensure that it's completely filled at 3300 lbs. Hence, I didvide the maximum height for the bar by the maximum value for the payload station: 80 / 3300 = 0.024242424.... For every lbs of payload, the bar will increase its height by 0.0242424... pixel. Multiplied with the current payload station weight, say 695 lbs, the resulting bar will therefor be 16.848484... = 17 pixel high (automatic rounding).
As a last safeguard, I tell the gauge parser that 80 pixel really is the absolute maximum value that the result of this mathematical operation should have. Hence the "80 min" (remember XML's handling of minimum and maximum values).
And that's all there is to it.
If you have a simulation variable that can't have values greater than 100 (e.g. landing gear percentage) and your bar's frame is 100 pixel high, you can even do away with the scaling factor and maximum value limiter. But I like to keep them in.
If you got this worked out, we can talk about how to drive the bar height's control variable with a timer.
(* How to limit payload station weights is an entirely different bit of science. It involves XMLTools.)