Let

Variables are used to store numbers in a sequence, and you can define them using the Let command.

Defining variables

Here the number 10 is stored inside a variable named DelayTime:

Let DelayTime = 10

You can then refer to the variable in later commands, as in this example:

Wait DelayTime Seconds

When this Wait command is played, the sequence will pause for 10 seconds.

Storing device properties

You can store a property of a device inside a variable, as in this example:

Let ArmPosition = Arm Position

When this command is played, the Position property of a Meccanoid Servo Motor named Arm will be stored inside a variable named ArmPosition.

Doing mathematics

Basic addition, subtraction, multiplication, and division of numbers can be achieved using variables:

Let Result = 4 + 2
Let Result = 4 - 2
Let Result = 4 * 2
Let Result = 4 / 2

While the plus ( + ) and minus ( - ) symbols are used for addition and subtraction, the asterisk ( * ) and slash ( / ) symbols are used for multiplication and division (instead of × and ÷) because you can type them on a keyboard.

Several more complex mathematical functions are also available. In the examples below the results of the functions, stored in the variable named Result, are given in brackets.

Refering to previously defined variables

You can refer to previously defined variables in a Let command:

Let A = 4
Let B = 2

Let Result = A + B

When this sequence is played, the variable Result will contain the number 6, the sum of variables A and B.

A variable can also refer to itself, which is useful for creating counter variables for use in loops.

In this loop, the Status LED will flash five times because the Counter variable is incremented for every play of the loop:

Let Counter = 0

Label
Start

Light Status
Wait 1 Second
Light Status Black
Wait 1 Second

Let Counter = Counter + 1

Jump To Start Until Counter = 5