The following script will animate a needle if the airspeed is over 80 kias, and the aircraft is off the ground.
The scalar will drive the needle from -1.0 to +1.0 over a 120º arc. The bias of +50 is such that frame 0 of the 100 frame animation will be the zero point...
Code:
<Animation name="CJ1_AoA_needle" guid="e5801d07-b465-4cdb-9b28-8327099a193c" length="100" type="Sim" typeParam2="CJ1_AoA_needle" typeParam="AutoPlay" />
<PartInfo>
<Name>CJ1_AoA_needle</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>
(A:Airspeed select indicated or true, knots) 80 < (A:SIM ON GROUND,bool) &&
if{ 0 }
els{ (A:INCIDENCE ALPHA, degrees) 0.0857143 * 50 + }
</Code>
</Parameter>
<Lag>10</Lag>
</Animation>
</PartInfo>
You will find quite a few examples of XML scripting here:
http://www.aerodynamika.com/cgi-bin/yabb2/YaBB.pl?board=XML
Simply put though, the task is to convert "some number" from FS into a format that will fit within the number of keyframes we plan to use in Max/GMax/FSDS. The most fundamental formula we need to remember is this:
SIM: Converts simvar to keyframes:
simvar * scale + bias = keyframes
Let's take a look at a simple example that will make use of the entire formula. Our task is to script a vertical speed indicator. Our VSI will indicate -6000 fpm to 6000 fpm, and we are going to use 300 frames for our animation. Why 300 frames instead of 100? Because the fewer frames we use the less accurate our VSI will be!
Now we know that the sim variable will be sent in absolute numbers, so the first thing we want to do is divide by 40, so the result will be -150 to +150 (we could do this any number of different ways, but this is the simplest solution)...
(A:VERTICAL SPEED, ft/min) 40 /
-or to "fit the formula" we could multiply by a scalar to get the same result-
(A:VERTICAL SPEED, ft/min) .025 *
Now because our zero point is at frame 150, we need to add the bias to the calculation...
simvar * scale + bias = keyframes
Code:
(A:VERTICAL SPEED, ft/min) .025 * 150 +
If we now plug in some numbers to validate our formula, the result is this table:
6000 * 0.25 + 150 = 300
0 * 0.25 + 150 = 150
-6000 * 0.25 + 150 = 0