Assigning Actions to User Variables:
Many people don't realise at first that you can assign absolutely any
data to a user variable. This can be commands like 'Move Forward' or 'Turn
Left'.
The advantage of this is that it is possible to plan in advance what
you are going to do, and then when the time comes, it can be done very
quickly, as there are now no calculations to be done.
Another slightly more subtle advantage is often evident in Torque. If
you want an action to happen on a particular sub-click (see Philip's SubClick
Tutorial for more info on this topic) then you can do something like:
scan relative 1
assign v1 move forward
if scan found mine then assign v1 move backward
~v1
This will always perform the action command on the
last line. If instead, you had used:
scan relative 1
if scan found mine then move backward
if scan found nothing then move forward
... then the action could happen on either of the
second or third lines. This can cause problems when something later in
the code desparately needs an extra sub-click. It can also be very frustrating
to debug, because this kind of problem will only happen when the cybug
scanned a mine.