1
0
Fork 0

Markus ZOJER: add wingSweep() wrapper

mf: add var keyword, use named args, ...
This commit is contained in:
mfranz 2007-11-29 13:16:13 +00:00
parent 46e35f9194
commit 62b3343fef

View file

@ -110,38 +110,46 @@ var carbHeatAxis = func {
# Wrapper around stepProps() which emulates the "old" flap behavior for # Wrapper around stepProps() which emulates the "old" flap behavior for
# configurations that aren't using the new mechanism. # configurations that aren't using the new mechanism.
# #
var flapsDown = func { var flapsDown = func(step) {
if(arg[0] == 0) { return; } if(step == 0) return;
if(props.globals.getNode("/sim/flaps") != nil) { if(props.globals.getNode("/sim/flaps") != nil) {
stepProps("/controls/flight/flaps", "/sim/flaps", arg[0]); stepProps("/controls/flight/flaps", "/sim/flaps", step);
return; return;
} }
# Hard-coded flaps movement in 3 equal steps: # Hard-coded flaps movement in 3 equal steps:
var val = 0.3333334 * arg[0] + getprop("/controls/flight/flaps"); var val = 0.3333334 * step + getprop("/controls/flight/flaps");
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 } setprop("/controls/flight/flaps", val > 1 ? 1 : val < 0 ? 0 : val);
setprop("/controls/flight/flaps", val);
} }
var stepSpoilers = func { var wingSweep = func(step) {
if(step == 0) return;
if(props.globals.getNode("/sim/wing-sweep") != nil) {
stepProps("/controls/flight/wing-sweep", "/sim/wing-sweep", step);
return;
}
# Hard-coded wing movement in 5 equal steps:
var val = 0.20 * step + getprop("/controls/flight/wing-sweep");
setprop("/controls/flight/wing-sweep", val > 1 ? 1 : val < 0 ? 0 : val);
}
var stepSpoilers = func(step) {
if(props.globals.getNode("/sim/spoilers") != nil) { if(props.globals.getNode("/sim/spoilers") != nil) {
stepProps("/controls/flight/spoilers", "/sim/spoilers", arg[0]); stepProps("/controls/flight/spoilers", "/sim/spoilers", step);
return; return;
} }
# Hard-coded spoilers movement in 4 equal steps: # Hard-coded spoilers movement in 4 equal steps:
var val = 0.25 * arg[0] + getprop("/controls/flight/spoilers"); var val = 0.25 * step + getprop("/controls/flight/spoilers");
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 } setprop("/controls/flight/spoilers", val > 1 ? 1 : val < 0 ? 0 : val);
setprop("/controls/flight/spoilers", val);
} }
var stepSlats = func { var stepSlats = func(step) {
if(props.globals.getNode("/sim/slats") != nil) { if(props.globals.getNode("/sim/slats") != nil) {
stepProps("/controls/flight/slats", "/sim/slats", arg[0]); stepProps("/controls/flight/slats", "/sim/slats", step);
return; return;
} }
# Hard-coded slats movement in 4 equal steps: # Hard-coded slats movement in 4 equal steps:
var val = 0.25 * arg[0] + getprop("/controls/flight/slats"); var val = 0.25 * step + getprop("/controls/flight/slats");
if(val > 1) { val = 1 } elsif(val < 0) { val = 0 } setprop("/controls/flight/slats", val > 1 ? 1 : val < 0 ? 0 : val);
setprop("/controls/flight/slats", val);
} }
## ##