> For the complete documentation index, see [llms.txt](https://zypec.gitbook.io/particles/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zypec.gitbook.io/particles/effects/creating-effect/script-types/condition.md).

# Condition

This page was last updated for version v1.2.0

## 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](/particles/effects/presets.md))
* 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 %}
