the code I have so far is this..
newdiesel-idle.nas
Code: Select all
#### Set Diesel idle level/cutoff with throttle position and mixture with altitude.
var pos_throttle = props.globals.getNode("/controls/engines/engine[0]/throttle");
var pos_mixture = props.globals.getNode("/controls/engines/engine[0]/mixture");
setlistener("/controls/engines/engine[0]/throttle", func {
var throttle = pos_throttle.getValue();
if (throttle >= 0.05) { pos_mixture.setValue(1.0); return 0; }
if (throttle > 0) { pos_mixture.setValue(0.068); return 0; }
pos_mixture.setValue(0);
});
#### Set mixture to alt level
setlistener("instrumentation/altimeter/pressure-alt-ft", func {
var alt = "instrumentation/altimeter/pressure-alt-ft";
var mixture = "controls/engines/engine[0]/mixture";
if (getprop(alt) > 15000) {
setprop (mixture, 0.69);
}
if (getprop(alt) < 15000) {
setprop (mixture, 0.78);
}
if (getprop(alt) > 10000) {
setprop (mixture, 0.78);
}
if (getprop(alt) < 10000) {
setprop (mixture, 0.85);
}
if (getprop(alt) > 5000) {
setprop (mixture, 0.85);
}
if (getprop(alt) < 5000) {
setprop (mixture, 0.94);
}
if (getprop(alt) > 3000) {
setprop (mixture, 0.94);
}
var MixtureInit = func {
settimer(env_effects, 2);
settimer(mixture_loop, 3); # Delay startup a bit to allow things to initialize
It's triggering a console complaint since I rewrote it. I'm wanting to initialize a stop to the first function and toggle on the second mixture change with altitude when the weight on the main float gear [1] is released when it's airborne. I don't know the syntax to write in to change which function changes the mixture's state.
Could someone help please?