Your method worked very well having only two scales, but I need more scales, e.g. from 0-20; 20-90; 90-200, and some in between that needed some tweaks. I tried doing this by "IF" method with no luck. So I decided to take a closer look at that table, and I finally figured it out! It's much simpler(and useful) than I thought. Also the rotation degrees from the table are the same in 3ds Max, and that saved time!
This is my custom table. The numbers(in 3ds Max degrees) increases by every 10 KNOTS.
const airspeed_tbl =
[0.0, 5.0, 10.0, 37.0, 63.0, 90.0, 117.0, 143.5, 170.0,
196.5, 208.5, 220.5, 232.5, 244.5 ,256.0, 268.0, 280.0, 292.0, 304.5, 316.0,
328.5];
And this is the rest of the script:
val = jsb['velocities/vc-kts']/10;
var idx = Math.floor(val);
if(idx >= airspeed_tbl.length - 2) idx = airspeed_tbl.length - 2;
val = airspeed_tbl[idx] + (airspeed_tbl[idx + 1] - airspeed_tbl[idx]) * (val - idx);
if((val)>=329){val = 329;} //<<<<<<<------------------------------------------I added this line to lock the needle to 200kts when you exceed the speed
geom.rotate_joint_orig(asi_needle_left, deg2rad(val), {x:0,y:0,z:-1});
geom.rotate_joint_orig(asi_needle_right, deg2rad(val), {x:0,y:0,z:-1});
geom.rotate_joint_orig(asi_needle_back, deg2rad(val), {x:0,y:0,z:-1});
As for the fuel indicator, it's much simpler with aircrafts, basically, the fuel consumption is calculated internally by JSBSim, and you only have to link it with the indicator, and of course indicate the capacity and content of each fuel tank in FDM.
This is the property to access to each fuel tank:
propulsion/tank[0]/contents-lbsBtw, if you look closer to Basler's script , you can see that the fuel needles actually indicates the fuel quantity of each tank (it has 6 tanks in total
).