Is there a way to get controls.throttleAxis to execute for conditions
other than the throttle input changing? Specifically, I want it to also
recalculate the throttle values when the rudder input changes. If I can
do this I can implement steering with differential engine thrust by
redefining controls.throttleAxis in my joystick file. Otherwise I think
I will have to have another function running in a loop continuously to
check the throttle input and make updates based on the rudder position.
Josh
If you're really curious, here's a code snippet, this of course does not
work yet and can be cleaned up quite a bit but you should be able to see
where I am going:
<nasal>
<script><![CDATA[
diffTInit = func {
engines = size(props.globals.getNode('/engines').getChildren());
if (engines != 1) {
# print('engines '~engines );
# Figure out left/right inboard engine numbers
left = int(engines/2)-1;
right = engines-left-1;
# print(left~' '~right);
# Figure out how much to retard each engine when turning
setsize(leftRatios, engines);
setsize(rightRatios, engines);
# print(size(leftRatios));
for (i=0; i<engines; i+=1) {
leftRatios[i] = i/(engines-1);
rightRatios[i] = 1-(i/(engines-1));
}
# Override throttleAxis
controls.throttleAxis = func {
val = cmdarg().getNode("setting").getValue();
if(size(arg) > 0) { val = -val; }
master = ((1 - val)/2);
turn = rudder.getValue();
if (turn<0) {
turn = -1 * turn;
}
turn = 1 - turn;
for (i=0; i<engines; i+=1) {
if (i < (left+1)) {
controlsEngines.getNode('engine['~i~']/throttle').setDoubleValue(master*leftRatios[i]*turn);
} elsif (i > (right-1)) {
controlsEngines.getNode('engine['~i~']/throttle').setDoubleValue(master);
} else {
controlsEngines.getNode('engine['~i~']/throttle').setDoubleValue(master);
}
}
}
print('Differential thrust initialised for '~engines~' engines.');
}
print('Differentail thrust not initialised.');
}
# define some stuff in this scope
engines = 0;
leftRatios = [];
rightRatios = [];
controlsEngines = props.globals.getNode('/controls/engines');
rudder = props.globals.getNode('/controls/flight/rudder');
settimer(diffTInit, 0);
]]></script>
</nasal>
_______________________________________________
Flightgear-devel mailing list
[email protected]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d