2007-10-07 15:12:05 +00:00
|
|
|
var startEngine = func {
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected");
|
|
|
|
var engs = props.globals.getNode("/controls/engines").getChildren("engine");
|
|
|
|
for(var i=0; i<size(engs); i+=1) {
|
|
|
|
var select = sel.getChild("engine", i);
|
2003-12-29 22:59:00 +00:00
|
|
|
if(select != nil and select.getValue() != 0) {
|
2003-12-22 20:05:18 +00:00
|
|
|
engs[i].getNode("starter").setBoolValue(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-29 22:59:00 +00:00
|
|
|
# Initialization hack (called after initialization via a timeout), to
|
|
|
|
# make sure that the number of engine properties in the selection tree
|
|
|
|
# match the actual number of engines. This should probably be fixed in a
|
|
|
|
# more elegant way...
|
2007-10-07 15:12:05 +00:00
|
|
|
var initSelectProps = func {
|
|
|
|
var engs = props.globals.getNode("/controls/engines").getChildren("engine");
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected");
|
|
|
|
for(var i=0; i<size(engs); i+=1) {
|
2003-12-29 22:59:00 +00:00
|
|
|
if(sel.getChild("engine", i) == nil) {
|
|
|
|
sel.getNode("engine[" ~ i ~ "]", 1); }}
|
|
|
|
}
|
|
|
|
settimer(initSelectProps, 0);
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var selectEngine = func {
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
|
|
|
|
foreach(var node; sel) { node.setBoolValue(node.getIndex() == arg[0]); }
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
|
2007-07-19 16:18:39 +00:00
|
|
|
# Selects (state=1) or deselects (state=0) a list of engines, or all
|
|
|
|
# engines if no list is specified. Example: selectEngines(1, 1, 3, 5);
|
|
|
|
#
|
|
|
|
var selectEngines = func (state, engines...) {
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected");
|
|
|
|
if(size(engines)) {
|
|
|
|
foreach(var e; engines)
|
|
|
|
sel.getChild("engine", e, 1).setBoolValue(state);
|
|
|
|
} else {
|
|
|
|
foreach(var e; sel.getChildren("engine"))
|
|
|
|
e.setBoolValue(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var selectAllEngines = func {
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
|
|
|
|
foreach(var node; sel) { node.setBoolValue(1); }
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var stepMagnetos = func {
|
|
|
|
var change = arg[0];
|
|
|
|
var engs = props.globals.getNode("/controls/engines").getChildren("engine");
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected");
|
|
|
|
for(var i=0; i<size(engs); i+=1) {
|
|
|
|
var select = sel.getChild("engine", i);
|
2003-12-29 22:59:00 +00:00
|
|
|
if(select != nil and select.getValue() != 0) {
|
2007-10-07 15:12:05 +00:00
|
|
|
var mag = engs[i].getNode("magnetos", 1);
|
2003-12-22 20:05:18 +00:00
|
|
|
mag.setIntValue(mag.getValue() + change);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var centerFlightControls = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
setprop("/controls/flight/elevator", 0);
|
|
|
|
setprop("/controls/flight/aileron", 0);
|
|
|
|
setprop("/controls/flight/rudder", 0);
|
|
|
|
}
|
|
|
|
|
2007-07-19 16:18:39 +00:00
|
|
|
var throttleMouse = func {
|
|
|
|
if(!getprop("/devices/status/mice/mouse[0]/button[1]")) return;
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
|
|
|
|
var delta = cmdarg().getNode("offset").getValue() * -4;
|
|
|
|
foreach(var n; sel) {
|
|
|
|
if(!n.getValue()) continue;
|
|
|
|
var throttle = "/controls/engines/engine[" ~ n.getIndex() ~ "]/throttle";
|
|
|
|
var val = getprop(throttle) + delta;
|
|
|
|
if(size(arg) > 0) val = -val;
|
|
|
|
setprop(throttle, val);
|
|
|
|
}
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Joystick axis handlers (uses cmdarg). Shouldn't be called from
|
|
|
|
# other contexts.
|
2007-07-19 16:18:39 +00:00
|
|
|
var throttleAxis = func {
|
|
|
|
var val = cmdarg().getNode("setting").getValue();
|
|
|
|
if(size(arg) > 0) val = -val;
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
|
|
|
|
foreach(var n; sel)
|
|
|
|
if(n.getValue())
|
|
|
|
setprop("/controls/engines/engine[" ~ n.getIndex() ~ "]/throttle",
|
|
|
|
(1 - val)/2);
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
2007-10-07 15:12:05 +00:00
|
|
|
var mixtureAxis = func {
|
|
|
|
var val = cmdarg().getNode("setting").getValue();
|
2003-12-22 20:05:18 +00:00
|
|
|
if(size(arg) > 0) { val = -val; }
|
|
|
|
props.setAll("/controls/engines/engine", "mixture", (1 - val)/2);
|
|
|
|
}
|
2007-10-07 15:12:05 +00:00
|
|
|
var propellerAxis = func {
|
|
|
|
var val = cmdarg().getNode("setting").getValue();
|
2003-12-22 20:05:18 +00:00
|
|
|
if(size(arg) > 0) { val = -val; }
|
|
|
|
props.setAll("/controls/engines/engine", "propeller-pitch", (1 - val)/2);
|
|
|
|
}
|
2007-10-07 15:12:05 +00:00
|
|
|
var carbHeatAxis = func {
|
|
|
|
var val = cmdarg().getNode("setting").getValue();
|
2005-06-20 16:52:58 +00:00
|
|
|
if(size(arg) > 0) { val = -val; }
|
|
|
|
props.setAll("/controls/anti-ice/engine", "carb-heat", (1 - val)/2);
|
|
|
|
}
|
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# Wrapper around stepProps() which emulates the "old" flap behavior for
|
|
|
|
# configurations that aren't using the new mechanism.
|
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var flapsDown = func {
|
2005-06-22 13:08:01 +00:00
|
|
|
if(arg[0] == 0) { return; }
|
2003-12-22 20:05:18 +00:00
|
|
|
if(props.globals.getNode("/sim/flaps") != nil) {
|
|
|
|
stepProps("/controls/flight/flaps", "/sim/flaps", arg[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
# Hard-coded flaps movement in 3 equal steps:
|
2007-10-07 15:12:05 +00:00
|
|
|
var val = 0.3333334 * arg[0] + getprop("/controls/flight/flaps");
|
2003-12-22 20:05:18 +00:00
|
|
|
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 }
|
|
|
|
setprop("/controls/flight/flaps", val);
|
|
|
|
}
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var stepSpoilers = func {
|
2004-06-01 08:13:12 +00:00
|
|
|
if(props.globals.getNode("/sim/spoilers") != nil) {
|
|
|
|
stepProps("/controls/flight/spoilers", "/sim/spoilers", arg[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
# Hard-coded spoilers movement in 4 equal steps:
|
2007-10-07 15:12:05 +00:00
|
|
|
var val = 0.25 * arg[0] + getprop("/controls/flight/spoilers");
|
2004-06-01 08:13:12 +00:00
|
|
|
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 }
|
|
|
|
setprop("/controls/flight/spoilers", val);
|
|
|
|
}
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var stepSlats = func {
|
2004-06-01 08:13:12 +00:00
|
|
|
if(props.globals.getNode("/sim/slats") != nil) {
|
|
|
|
stepProps("/controls/flight/slats", "/sim/slats", arg[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
# Hard-coded slats movement in 4 equal steps:
|
2007-10-07 15:12:05 +00:00
|
|
|
var val = 0.25 * arg[0] + getprop("/controls/flight/slats");
|
2004-06-01 08:13:12 +00:00
|
|
|
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 }
|
|
|
|
setprop("/controls/flight/slats", val);
|
|
|
|
}
|
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# Steps through an "array" of property settings. The first argument
|
|
|
|
# specifies a destination property. The second is a string containing
|
|
|
|
# a global property tree. This tree should contain an array of
|
|
|
|
# indexed <setting> children. This function will maintain a
|
|
|
|
# <current-setting> child, which contains the index of the currently
|
|
|
|
# active setting. The third argument specifies an integer delta,
|
|
|
|
# indicating how many steps to move through the setting array.
|
|
|
|
# Note that because of the magic of the property system, this
|
|
|
|
# mechanism works for all scalar property types (bool, int, double,
|
|
|
|
# string).
|
|
|
|
#
|
|
|
|
# TODO: This interface could easily be extended to allow for wrapping,
|
|
|
|
# in addition to clamping, allowing a "cycle" of settings to be
|
|
|
|
# defined. It could also be hooked up with the interpolate() call,
|
|
|
|
# which would allow the removal of the transition-time feature from
|
|
|
|
# YASim. Finally, other pre-existing features (the views and engine
|
|
|
|
# magnetos, for instance), work similarly but not compatibly, and
|
|
|
|
# could be integrated.
|
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var stepProps = func {
|
|
|
|
var dst = props.globals.getNode(arg[0]);
|
|
|
|
var array = props.globals.getNode(arg[1]);
|
|
|
|
var delta = arg[2];
|
2003-12-22 20:05:18 +00:00
|
|
|
if(dst == nil or array == nil) { return; }
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var sets = array.getChildren("setting");
|
2003-12-22 20:05:18 +00:00
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var curr = array.getNode("current-setting", 1).getValue();
|
2003-12-22 20:05:18 +00:00
|
|
|
if(curr == nil) { curr = 0; }
|
|
|
|
curr = curr + delta;
|
|
|
|
if (curr < 0) { curr = 0; }
|
|
|
|
elsif(curr >= size(sets)) { curr = size(sets) - 1; }
|
|
|
|
|
|
|
|
array.getNode("current-setting").setIntValue(curr);
|
|
|
|
dst.setValue(sets[curr].getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# "Slews" a property smoothly, without dependence on the simulator
|
|
|
|
# frame rate. The first argument is the property name. The second is
|
2004-02-10 18:12:09 +00:00
|
|
|
# a rate, in units per second. NOTE: this modifies the property for
|
|
|
|
# the current frame only; it is intended to be called by bindings
|
|
|
|
# which repeat each frame. If you want to cause motion over time, see
|
|
|
|
# interpolate().
|
2003-12-22 20:05:18 +00:00
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var slewProp = func(prop, delta) {
|
|
|
|
delta *= getprop("/sim/time/delta-realtime-sec");
|
2003-12-22 20:05:18 +00:00
|
|
|
setprop(prop, getprop(prop) + delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Standard trim rate, in units per second. Remember that the full
|
|
|
|
# range of a trim axis is 2.0. Should probably read this out of a
|
|
|
|
# property...
|
2007-10-07 15:12:05 +00:00
|
|
|
var TRIM_RATE = 0.045;
|
2003-12-22 20:05:18 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# Handlers. These are suitable for binding to repeatable button press
|
|
|
|
# events. They are *not* good for binding to the keyboard, since (at
|
|
|
|
# least) X11 synthesizes its own key repeats.
|
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var elevatorTrim = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
slewProp("/controls/flight/elevator-trim", arg[0] * TRIM_RATE); }
|
2007-10-07 15:12:05 +00:00
|
|
|
var aileronTrim = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
slewProp("/controls/flight/aileron-trim", arg[0] * TRIM_RATE); }
|
2007-10-07 15:12:05 +00:00
|
|
|
var rudderTrim = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
slewProp("/controls/flight/rudder-trim", arg[0] * TRIM_RATE); }
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var THROTTLE_RATE = 0.33;
|
2003-12-22 20:05:18 +00:00
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var adjThrottle = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
adjEngControl("throttle", arg[0]); }
|
2007-10-07 15:12:05 +00:00
|
|
|
var adjMixture = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
adjEngControl("mixture", arg[0]); }
|
2007-10-07 15:12:05 +00:00
|
|
|
var adjCondition = func {
|
2005-04-21 14:39:00 +00:00
|
|
|
adjEngControl("condition", arg[0]); }
|
2007-10-07 15:12:05 +00:00
|
|
|
var adjPropeller = func {
|
2003-12-22 20:05:18 +00:00
|
|
|
adjEngControl("propeller-pitch", arg[0]); }
|
|
|
|
|
2007-10-07 15:12:05 +00:00
|
|
|
var adjEngControl = func {
|
|
|
|
var engs = props.globals.getNode("/controls/engines").getChildren("engine");
|
|
|
|
var selected = props.globals.getNode("/sim/input/selected");
|
|
|
|
var delta = arg[1] * THROTTLE_RATE * getprop("/sim/time/delta-realtime-sec");
|
|
|
|
foreach(var e; engs) {
|
2006-03-04 18:21:06 +00:00
|
|
|
if(selected.getChild("engine", e.getIndex(), 1).getBoolValue()) {
|
2007-10-07 15:12:05 +00:00
|
|
|
var node = e.getNode(arg[0], 1);
|
2006-03-04 18:21:06 +00:00
|
|
|
node.setValue(node.getValue() + delta);
|
|
|
|
}
|
2003-12-22 20:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-31 19:55:13 +00:00
|
|
|
##
|
|
|
|
# arg[0] is the throttle increment
|
|
|
|
# arg[1] is the auto-throttle target speed increment
|
2007-07-19 16:18:39 +00:00
|
|
|
var incThrottle = func {
|
|
|
|
var auto = props.globals.getNode("/autopilot/locks/speed", 1);
|
|
|
|
var sel = props.globals.getNode("/sim/input/selected");
|
2007-10-07 15:12:05 +00:00
|
|
|
if (!auto.getValue()) {
|
|
|
|
var engs = props.globals.getNode("/controls/engines").getChildren("engine");
|
|
|
|
foreach(var e; engs) {
|
|
|
|
if(sel.getChild("engine", e.getIndex(), 1).getBoolValue()) {
|
|
|
|
var node = e.getNode("throttle", 1);
|
|
|
|
var val = node.getValue() + arg[0];
|
|
|
|
node.setValue(val < -1.0 ? -1.0 : val > 1.0 ? 1.0 : val);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-10-07 15:12:05 +00:00
|
|
|
var node = props.globals.getNode("/autopilot/settings/target-speed-kt", 1);
|
|
|
|
if (node.getValue() == nil) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
|
|
|
node.setValue(node.getValue() + arg[1]);
|
|
|
|
if (node.getValue() < 0.0) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# arg[0] is the aileron increment
|
|
|
|
# arg[1] is the autopilot target heading increment
|
2007-10-07 15:12:05 +00:00
|
|
|
var incAileron = func {
|
|
|
|
var auto = props.globals.getNode("/autopilot/locks/heading", 1);
|
|
|
|
if (!auto.getValue()) {
|
|
|
|
var aileron = props.globals.getNode("/controls/flight/aileron");
|
|
|
|
if (aileron.getValue() == nil) {
|
|
|
|
aileron.setValue(0.0);
|
|
|
|
}
|
|
|
|
aileron.setValue(aileron.getValue() + arg[0]);
|
|
|
|
if (aileron.getValue() < -1.0) {
|
|
|
|
aileron.setValue(-1.0);
|
|
|
|
}
|
|
|
|
if (aileron.getValue() > 1.0) {
|
|
|
|
aileron.setValue(1.0);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
2007-10-07 15:12:05 +00:00
|
|
|
if (auto.getValue() == "dg-heading-hold") {
|
|
|
|
var node = props.globals.getNode("/autopilot/settings/heading-bug-deg", 1);
|
|
|
|
if (node.getValue() == nil) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
|
|
|
node.setValue(node.getValue() + arg[1]);
|
|
|
|
if (node.getValue() < 0.0) {
|
|
|
|
node.setValue(node.getValue() + 360.0);
|
|
|
|
}
|
|
|
|
if (node.getValue() > 360.0) {
|
|
|
|
node.setValue(node.getValue() - 360.0);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
2007-10-07 15:12:05 +00:00
|
|
|
if (auto.getValue() == "true-heading-hold") {
|
|
|
|
var node = props.globals.getNode("/autopilot/settings/true-heading-deg", 1);
|
|
|
|
if (node.getValue() == nil) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
|
|
|
node.setValue(node.getValue() + arg[1]);
|
|
|
|
if (node.getValue() < 0.0) {
|
|
|
|
node.setValue(node.getValue() + 360.0);
|
|
|
|
}
|
|
|
|
if (node.getValue() > 360.0) {
|
|
|
|
node.setValue(node.getValue() - 360.0);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# arg[0] is the elevator increment
|
2007-06-22 18:49:38 +00:00
|
|
|
# arg[1] is the autopilot target altitude increment
|
2007-10-07 15:12:05 +00:00
|
|
|
var incElevator = func {
|
|
|
|
var auto = props.globals.getNode("/autopilot/locks/altitude", 1);
|
|
|
|
if (!auto.getValue() or auto.getValue() == 0) {
|
|
|
|
var elevator = props.globals.getNode("/controls/flight/elevator");
|
|
|
|
if (elevator.getValue() == nil) {
|
|
|
|
elevator.setValue(0.0);
|
|
|
|
}
|
|
|
|
elevator.setValue(elevator.getValue() + arg[0]);
|
|
|
|
if (elevator.getValue() < -1.0) {
|
|
|
|
elevator.setValue(-1.0);
|
|
|
|
}
|
|
|
|
if (elevator.getValue() > 1.0) {
|
|
|
|
elevator.setValue(1.0);
|
|
|
|
}
|
|
|
|
} elsif (auto.getValue() == "altitude-hold") {
|
|
|
|
var node = props.globals.getNode("/autopilot/settings/target-altitude-ft", 1);
|
|
|
|
if (node.getValue() == nil) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
|
|
|
node.setValue(node.getValue() + arg[1]);
|
|
|
|
if (node.getValue() < 0.0) {
|
|
|
|
node.setValue(0.0);
|
|
|
|
}
|
2004-01-31 19:55:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# Joystick axis handlers. Don't call from other contexts.
|
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var elevatorTrimAxis = func { elevatorTrim(cmdarg().getNode("value").getValue()); }
|
|
|
|
var aileronTrimAxis = func { aileronTrim(cmdarg().getNode("value").getValue()); }
|
|
|
|
var rudderTrimAxis = func { rudderTrim(cmdarg().getNode("value").getValue()); }
|
2003-12-22 20:05:18 +00:00
|
|
|
|
2006-03-04 18:21:06 +00:00
|
|
|
##
|
|
|
|
# Gear handling.
|
|
|
|
#
|
2007-10-07 15:12:05 +00:00
|
|
|
var gearDown = func(v) {
|
|
|
|
if (v < 0) {
|
2005-06-22 13:08:01 +00:00
|
|
|
setprop("/controls/gear/gear-down", 0);
|
2007-10-07 15:12:05 +00:00
|
|
|
} elsif (v > 0) {
|
2005-06-22 13:08:01 +00:00
|
|
|
setprop("/controls/gear/gear-down", 1);
|
|
|
|
}
|
|
|
|
}
|
2007-07-13 13:46:09 +00:00
|
|
|
var gearToggle = func { gearDown(getprop("/controls/gear/gear-down") > 0 ? -1 : 1); }
|
2005-06-22 13:08:01 +00:00
|
|
|
|
2006-03-04 18:21:06 +00:00
|
|
|
##
|
|
|
|
# Brake handling.
|
|
|
|
#
|
2007-07-13 13:46:09 +00:00
|
|
|
var fullBrakeTime = 0.5;
|
|
|
|
var applyBrakes = func(v, which = 0) {
|
2006-03-01 18:33:46 +00:00
|
|
|
if (which <= 0) { interpolate("/controls/gear/brake-left", v, fullBrakeTime); }
|
|
|
|
if (which >= 0) { interpolate("/controls/gear/brake-right", v, fullBrakeTime); }
|
2006-03-01 17:04:20 +00:00
|
|
|
}
|
|
|
|
|
2007-07-13 13:46:09 +00:00
|
|
|
var applyParkingBrake = func(v) {
|
2006-03-01 17:04:20 +00:00
|
|
|
if (!v) { return; }
|
|
|
|
var p = "/controls/gear/brake-parking";
|
2006-03-01 18:33:46 +00:00
|
|
|
setprop(p, var i = !getprop(p));
|
|
|
|
return i;
|
2006-03-01 17:04:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 20:52:03 +00:00
|
|
|
##
|
|
|
|
# Weapon handling.
|
|
|
|
#
|
2007-07-13 13:46:09 +00:00
|
|
|
var trigger = func(b) setprop("/controls/armament/trigger", b);
|
|
|
|
var weaponSelect = func(d) {
|
2006-06-24 12:31:58 +00:00
|
|
|
var ws = props.globals.getNode("/controls/armament/selected", 1);
|
|
|
|
var n = ws.getValue();
|
|
|
|
if (n == nil) { n = 0; }
|
|
|
|
ws.setIntValue(n + d);
|
|
|
|
}
|
2006-06-09 20:52:03 +00:00
|
|
|
|
2007-07-13 13:46:09 +00:00
|
|
|
##
|
|
|
|
# Communication.
|
|
|
|
#
|
|
|
|
var ptt = func(b) setprop("/instrumentation/comm/ptt", b);
|
|
|
|
|