-
Throttle Airspeed expression
Hi all,
I’m making a dynamic readout based on one Expression Slider called Knots, which is set to slide between 100-1650 (roughly MACH 2.5). This gets linked into a text layer. The word “KNOTS” get replaced by the word “MACH” when the speed of sound is achieved and also the numerical readout goes into “Mach mode” where it shows the Mach value instead of Knots.
v=thisComp.layer("Throttle Controller").effect("Knots")("Slider")
K=" KNOTS"
M=" MACH"
mNum=Math.round(v/661.7*1000)/1000
if (v>661.7) (TXT=M) else (TXT=K);
if (v<661.7) (""+Math.round(v)+TXT) else (""+mNum+TXT)
The trouble I am having is that I want MACH Mode to always show 3 decimal places. And actually, now that I look at this code, I’d like to change the visual style and show BOTH Knots and Mach. Getting them both to display shouldn’t be a problem, but how can I get the Mach section to always show 3 decimals (i.e. 0.500 or 1.300 instead of .5 or 1.3)?
And, for extra credit, I think it would look real nifty if the Mach line turned red and then back to white over half a second (15 frames) after hitting Mach 1. Just a little red attractor pulse.
Oh, and I’ll add the Mach altitude conversion later when I create the altimeter. 😉
//I guess this would be (close to) the newer expression, really guessing here
v=thisComp.layer("Throttle Controller").effect("Knots")("Slider")
mNum=Math.round(v/661.7*1000)/1000
""+Math.round(v)+" KNOTS" r
"MACH "+""+mNum