---
description: This page was last updated for version v1.2.0
---

# Condition

## Format

`conditional (condition) ? execute-if-condition-is-true : execute-if-condition-is-false`

## **Examples**

1.  `conditional (timer>=20) ? variable timer=0 : variable timer+=1`

    > Set the _timer_ to 0 when the _timer_ is greater than or equal to 20

    > Add 1 to the _timer_ when the _timer_ is less than 20
2.  `conditional (reverse==1 && x>90) ? variable reverse=0 : none`

    > Set _reverse_ to 0 when _reverse_ is equal to 1 and _x_ is greater than 90

    > Otherwise, do nothing
3.  `conditional ((reverse==1 && x>90) || (reverse!=1 && x<0)) ? preset play-sound : none`

    > Play sound when (the _reverse_ is equal to 1 and _x_ is greater than 90) or (the _reverse_ is not equal to 1 and _x_ is less than 0)

    > Otherwise, do nothing

{% hint style="warning" %}
You must put the conditions between `()`
{% endhint %}

{% hint style="info" %}
You cannot put a condition inside a condition but you can define a preset for that:

* Create a preset in _presets.yml_ (see [Presets](../../presets))
* In your condition, put the preset into the correct place

#### Example

`presets.yml`

```yaml
reverse: "conditional (stepY>60) ? variable reverse=0 : none"
```

`effects.yml`

```yaml
..
scripts:
  - "conditional (reverse==1) ? preset reverse : none"
..
```
{% endhint %}

{% hint style="info" %}
You can add mathematical equations in conditions:

* Put the variables inside `{}` to enable equations

#### Example

<pre class="language-yaml"><code class="lang-yaml"><strong>- "conditional ({TIMER}%20==0) ? preset reset-things : return"
</strong></code></pre>
{% endhint %}
