Add a (test) script to open and close the doors of the bo105.
This commit is contained in:
parent
0abab4423f
commit
df52e98fd8
1 changed files with 36 additions and 0 deletions
36
Nasal/bo105.nas
Normal file
36
Nasal/bo105.nas
Normal file
|
@ -0,0 +1,36 @@
|
|||
# $Id$
|
||||
print("Loading bo105.nas");
|
||||
print("\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");
|
Loading…
Add table
Reference in a new issue