1
0
Fork 0

- drop cmdarg() usage in listener functions

- use var keyword
This commit is contained in:
mfranz 2008-10-12 18:50:06 +00:00
parent 838dff7b5f
commit 0b453c6da3

View file

@ -17,26 +17,26 @@
# You can define multiple max-flap-extension-speed entries for max extension # You can define multiple max-flap-extension-speed entries for max extension
# speeds for different flap settings. # speeds for different flap settings.
checkFlaps = func { var checkFlaps = func(n) {
flapsetting = cmdarg().getValue(); var flapsetting = n.getValue();
if (flapsetting == 0) if (flapsetting == 0)
return; return;
airspeed = getprop("velocities/airspeed-kt"); var airspeed = getprop("velocities/airspeed-kt");
ltext = ""; var ltext = "";
limits = props.globals.getNode("limits"); var limits = props.globals.getNode("limits");
if ((limits != nil) and (limits.getChildren("max-flap-extension-speed") != nil)) if ((limits != nil) and (limits.getChildren("max-flap-extension-speed") != nil))
{ {
children = limits.getChildren("max-flap-extension-speed"); var children = limits.getChildren("max-flap-extension-speed");
foreach(c; children) foreach(c; children)
{ {
if ((c.getChild("flaps") != nil) and if ((c.getChild("flaps") != nil) and
(c.getChild("speed") != nil) ) (c.getChild("speed") != nil) )
{ {
flaps = c.getChild("flaps").getValue(); var flaps = c.getChild("flaps").getValue();
speed = c.getChild("speed").getValue(); var speed = c.getChild("speed").getValue();
if ((flaps != nil) and if ((flaps != nil) and
(speed != nil) and (speed != nil) and
@ -56,12 +56,12 @@ checkFlaps = func {
} }
checkGear = func { var checkGear = func(n) {
if (!cmdarg().getValue()) if (!n.getValue())
return; return;
airspeed = getprop("velocities/airspeed-kt"); var airspeed = getprop("velocities/airspeed-kt");
max_gear = getprop("limits/max-gear-extension-speed"); var max_gear = getprop("limits/max-gear-extension-speed");
if ((max_gear != nil) and (airspeed > max_gear)) if ((max_gear != nil) and (airspeed > max_gear))
{ {
@ -75,12 +75,12 @@ setlistener("controls/flight/flaps", checkFlaps);
setlistener("controls/gear/gear-down", checkGear); setlistener("controls/gear/gear-down", checkGear);
# =============================== Pilot G stuff (taken from hurricane.nas) ================================= # =============================== Pilot G stuff (taken from hurricane.nas) =================================
pilot_g = props.globals.getNode("fdm/jsbsim/accelerations/a-pilot-z-ft_sec2", 1); var pilot_g = props.globals.getNode("fdm/jsbsim/accelerations/a-pilot-z-ft_sec2", 1);
pilot_g.setDoubleValue(0); pilot_g.setDoubleValue(0);
var g_damp = 0; var g_damp = 0;
updatePilotG = func { var updatePilotG = func {
var g = pilot_g.getValue() ; var g = pilot_g.getValue() ;
#if (g == nil) { g = 0; } #if (g == nil) { g = 0; }
g_damp = ( g * 0.2) + (g_damp * 0.8); g_damp = ( g * 0.2) + (g_damp * 0.8);
@ -90,16 +90,16 @@ updatePilotG = func {
updatePilotG(); updatePilotG();
checkGandVNE = func { var checkGandVNE = func {
if (getprop("/sim/freeze/replay-state")) if (getprop("/sim/freeze/replay-state"))
return; return;
max_positive = getprop("limits/max-positive-g"); var max_positive = getprop("limits/max-positive-g");
max_negative = getprop("limits/max-negative-g"); var max_negative = getprop("limits/max-negative-g");
msg = ""; var msg = "";
# Convert the ft/sec^2 into Gs - allowing for gravity. # Convert the ft/sec^2 into Gs - allowing for gravity.
g = (- g_damp) / 32; var g = (- g_damp) / 32;
if ((max_positive != nil) and (g > max_positive)) if ((max_positive != nil) and (g > max_positive))
{ {
@ -112,8 +112,8 @@ checkGandVNE = func {
} }
# Now check VNE # Now check VNE
airspeed = getprop("velocities/airspeed-kt"); var airspeed = getprop("velocities/airspeed-kt");
vne = getprop("limits/vne"); var vne = getprop("limits/vne");
if ((airspeed != nil) and (vne != nil) and (airspeed > vne)) if ((airspeed != nil) and (vne != nil) and (airspeed > vne))
{ {