# Execution Modes

Before even coding, you need to select an execution mode for your Control Block. At the moment, there are 3 different execution modes available and built-in that can help you in various ways.

<div data-with-frame="true"><figure><img src="/files/LKF8qlUXPSmDaU5DRvPw" alt=""><figcaption><p>The image shows the 3 modes in the Control Block interface.</p></figcaption></figure></div>

### Pulse Mode

The Pulse mode is the mode selected by default.

This means that your code will be executed on a redstone signal (Example: Lever, Button, Pressure Plate, ...).&#x20;

Example:

{% code lineNumbers="true" %}

```
-- ControlScript
var number = 5
var bonus = 2
var total = number + bonus

run(give @p minecraft:diamonds total)
log("Gave "..total.." diamonds to the nearest player!") 
```

{% endcode %}

In pulse mode, if a button is pressed once, the nearest player will receive 7 diamonds, and you will see the following message appear in the chat: `Gave 7 diamonds to the nearest player!`. This will happen each time someone presses the said button.

### Repeat Mode

On repeat mode, you will see a "Ticks" field appear. On repeat mode, your script will execute each X ticks that you have defined in the Ticks field.

<div data-with-frame="true"><figure><img src="/files/0SUAobbiwo0vB46grTkp" alt=""><figcaption></figcaption></figure></div>

No need for any redstone signal.

Example:

{% code lineNumbers="true" %}

```
-- ControlScript
var number = 5
var bonus = 2
var total = number + bonus

run(give @p minecraft:diamonds total)
log("Gave "..total.." diamonds to the nearest player!") 
```

{% endcode %}

Mode: `Repeat`\
Ticks: `50`

In repeat mode, the nearest player will receive 7 diamonds, and you will see the following message appear in the chat: `Gave 7 diamonds to the nearest player!` every 50 ticks. This will happen until the block is broken or the Mode/Script is changed.

{% hint style="warning" %}
Be carefull with repeating control blocks that execute commands like kick, kill, ...\
\
Incase something happends, that requires you to disable control blocks, use the commands.\
0.9.0: `/controlblocks enabled=false` and `/controlblocks enabled=true`\
1.0.0+: `/controlblocks enabled false` and `/controlblocks enabled true`\
\
**We are not responsible for any loss or dammage to any world.**
{% endhint %}

### Redstone Mode

The redstone mode is the same as the repeat mode, except it will only repeat as long as there is a redstone signal going into the block.

Example:

{% code lineNumbers="true" %}

```
-- ControlScript
var number = 5
var bonus = 2
var total = number + bonus

run(give @p minecraft:diamonds total)
log("Gave "..total.." diamonds to the nearest player!") 
```

{% endcode %}

Mode: `Redstone`\
Ticks: `50`

In restone mode, the nearest player will receive 7 diamonds, and you will see the following message appear in the chat: `Gave 7 diamonds to the nearest player!` every 50 ticks if a redstone signal is going in the block. As soon the redstone signal is no more, the block will stop repeating. This will happen until the block is broken, redstone signal off or the Mode/Script is changed.

{% hint style="warning" %}
Be carefull with repeating control blocks that execute commands like kick, kill, ...\
\
Incase something happends, that requires you to disable control blocks, use the commands.\
0.9.0: `/controlblocks enabled=false` and `/controlblocks enabled=true`\
1.0.0+: `/controlblocks enabled false` and `/controlblocks enabled true`\
\
**We are not responsible for any loss or dammage to any world.**
{% endhint %}


---

# 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://control-blocks-mod.gitbook.io/control-blocks-mod-docs/controlscript/execution-modes.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.
