From df52e98fd8cefd79c8493881c43506874982d33d Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 28 Nov 2003 12:19:49 +0000 Subject: [PATCH] Add a (test) script to open and close the doors of the bo105. --- Nasal/bo105.nas | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Nasal/bo105.nas diff --git a/Nasal/bo105.nas b/Nasal/bo105.nas new file mode 100644 index 000000000..78dd91fe1 --- /dev/null +++ b/Nasal/bo105.nas @@ -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");