Add abs() and interpolate() to globals. Move bo105 code to the -set.xml file
This commit is contained in:
parent
2c92f74b9f
commit
5ed2c89605
2 changed files with 30 additions and 41 deletions
|
@ -1,41 +0,0 @@
|
||||||
# $Id$
|
|
||||||
#print("Loading bo105.nas");
|
|
||||||
if (streq(getprop("/sim/aero"), "bo105")) {
|
|
||||||
print(
|
|
||||||
"Additional key bindings for the bo105 helicopter:\n\n",
|
|
||||||
"\tShift-C ... open/close rear door"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
rearpos = "/controls/doors/rear";
|
|
||||||
rearstep = "/controls/doors/rear-state";
|
|
||||||
setprop(rearstep, 0);
|
|
||||||
|
|
||||||
reardoor = func {
|
|
||||||
pos = getprop(rearpos);
|
|
||||||
step = getprop(rearstep);
|
|
||||||
if (pos == 0 or step < 0) {
|
|
||||||
setprop(rearstep, 0.02);
|
|
||||||
} elsif (pos == 1 or step > 0) {
|
|
||||||
setprop(rearstep, -0.02);
|
|
||||||
}
|
|
||||||
settimer(MoveDoor, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
MoveDoor = func {
|
|
||||||
pos = getprop(rearpos);
|
|
||||||
step = getprop(rearstep);
|
|
||||||
if (pos + step >= 0 and pos + step <= 1) {
|
|
||||||
setprop(rearpos, pos + step);
|
|
||||||
settimer(MoveDoor, 0.05);
|
|
||||||
} else {
|
|
||||||
if (step < 0) {
|
|
||||||
setprop(rearpos, 0);
|
|
||||||
} elsif (step > 0) {
|
|
||||||
setprop(rearpos, 1);
|
|
||||||
}
|
|
||||||
setprop(rearstep, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#print("Finished loading bo105.nas");
|
|
|
@ -31,3 +31,33 @@ fgcommand = func {
|
||||||
# props.Node object.
|
# props.Node object.
|
||||||
#
|
#
|
||||||
cmdarg = func { props.wrapNode(_cmdarg()) }
|
cmdarg = func { props.wrapNode(_cmdarg()) }
|
||||||
|
|
||||||
|
##
|
||||||
|
# Utility. Does what it you think it does.
|
||||||
|
#
|
||||||
|
abs = func { if(arg[0] < 0) { -arg[0] } else { arg[0] } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# Convenience wrapper for the _interpolate function. Takes a
|
||||||
|
# single string or props.Node object in arg[0] indicating a target
|
||||||
|
# property, and a variable-length list of time/value pairs. Example:
|
||||||
|
#
|
||||||
|
# interpolate("/animations/radar/angle",
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0,
|
||||||
|
# 180, 1, 360, 1, 0, 0);
|
||||||
|
#
|
||||||
|
# This will swing the "radar dish" smoothly through 8 revolutions over
|
||||||
|
# 16 seconds. Note the use of zero-time interpolation between 360 and
|
||||||
|
# 0 to wrap the interpolated value properly.
|
||||||
|
#
|
||||||
|
interpolate = func {
|
||||||
|
if(isa(arg[0], props.Node)) { arg[0] = arg[0]._g; }
|
||||||
|
elsif(typeof(arg[0]) != "scalar") { return; }
|
||||||
|
_interpolate(arg[0], subvec(arg, 1));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue