Thanks Sigmoid! I agree that your design is much more elegant, I admit that I wasn't quite a polished programmer and I might have been looking for an easy method to explain that didn't require too many typing (I write a lot on my iPod -- doesn't mean that I necessarily prefer it!). With regard to the loops, perhaps you could improve on my method by using the "loopid" method outlined here:
http://wiki.flightgear.org/Nasal_Loops. It is a bit tricky for joysticks, for you don't know whether the initialization was run or not. Hence I think this method would work in the initialization section at the top:
- Code: Select all
if (contains(caller(0)[0], "loopid"))
loopid += 1;
else var loopid = 0;
Here caller(0) is the currently executing function which returns a vector, the index=0 of which is the local namespace as a hash (well, namespaces
are hashes), and contains checks for a key in the has, aka a variable in the current namespace in this case. If we don't find it, then we want to create it with 0, but just increment it if it is already there. Make sense?