# Control

### 1. wait () seconds <a href="#id-1-wait--seconds" id="id-1-wait--seconds"></a>

Wait for a specified period of time to run the script.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-1-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-1-2.png)

Press Button A. One second later, Codey's screen will display the image.

### 2. repeat () <a href="#id-2-repeat" id="id-2-repeat"></a>

Run the script for the specified number of times.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-2-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-2-2.png)

When Codey starts up, it will play the sound "hello" for ten times.

### 3. forever <a href="#id-3-forever" id="id-3-forever"></a>

Run the script repeatedly.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-3-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-3-2.png)

When Codey starts up, Codey's will repeated display the two images consecutively.

### 4. if () then () <a href="#id-4-if-then" id="id-4-if-then"></a>

If the report condition is met, run the script.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-4-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-4-2.png)

When Codey starts up, if being shaken, Codey will play the sound "hello".

### 5. if () then () else () <a href="#id-5-if-then-else" id="id-5-if-then-else"></a>

If the report condition is met, run script 1. If not, run script 2.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-5-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-5-2.png)

When Codey starts up, if there are obstacles ahead, Codey Rocky will stop moving. If not, Codey Rocky will keep moving forward at 50% power.

### 6. wait () <a href="#id-6-wait" id="id-6-wait"></a>

Wait until the report condition is met. Run the script.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-6-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-6-2.png)

After starting up, Codey Rocky will keep moving forward at 50% power until Rocky detects obstacles ahead.

### 7. repeat until () <a href="#id-7-repeat-until" id="id-7-repeat-until"></a>

Run the script repeatedly until the report condition is met.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-7-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-7-2.png)

After starting up, Codey Rocky will keep moving forward at 50% power until Rocky detects obstacles ahead.

### 8. stop () <a href="#id-8-stop" id="id-8-stop"></a>

Stop the specified script or scripts. There are three options: all, this script, or other scripts in sprite.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-8-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/control-8-2.png)

Press Button A to stop all scripts.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pakronics.com.au/primary/codey-rocky-ai-robot/block-reference/control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
