Tips and Tricks


ALIAS Keyword

One of the more useful script commands is the ALIAS command. You can use it to chain commands together to create more "complex" commands. You can assign this command sequence to a variable, and then run all those commands at once, simply by calling the variable.

For example, let's say you were creating a dance sequence for your Robot, and you wanted it to move in a square (waltz) every so often. Instead of calling the following commands:

MOVE FORWARD 2F
ROTATE CW 90
MOVE FORWARD 2F
ROTATE CW 90
MOVE FORWARD 2F
ROTATE CW 90
MOVE FORWARD 2F
ROTATE CW 90

Over and over, you could assign these commands to a variable called $Waltz :

ALIAS $Waltz MOVE FORWARD 2F; ROTATE CW 90; MOVE FORWARD 2F; ROTATE CW 90; MOVE FORWARD 2F; ROTATE CW 90; MOVE FORWARD 2F; ROTATE CW 90

And now whenever you want your Robot to move in a square, simply execute the line:

$Waltz

In your script.




Maintaining state between sessions.

Did you know what each time you quit BRAIN it stores all of your variables in a file called variables.txt? And next time BRAIN starts up, it loads those variables into memory?

This gives your Robot a "memory". Scripts can maintain state between sessions, or remember what happened in a previous session.

You can also create custom variables in that file, that you can use in scripts. For example, your name, so your Robot "knows" you.




The Robot command window also accepts script commands.

Did you know that you can enter script commands in the Robot command panel? This is especially useful to test out small script sequences or to enter script commands without having to create a command first.

For example, you can type in commands such as:

Move forward 10i
Say $DATE
etc.,

Directly in the Robot command panel.