<commit_before># Conditions

{% tabs %}
{% tab title="With one pattern" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] condition <pattern>:
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}

{% tab title="With multiple patterns" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] condition:
  patterns:
    # patterns, one per line
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}

{% tab title="Property condition" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] <skript type> property condition <pattern>:
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}
{% endtabs %}

### Flag `local`

Specifying that a condition is `local` makes the condition only usable from within the script that it is defined in. This allows you to create condition that do not interfere with conditions from other addons or scripts.

{% hint style="info" %}
Local conditions are guaranteed to be parsed before other custom conditions, but not necessarily before conditions from other addons.
{% endhint %}

### Section `parse`

Code in this section is executed whenever the condition is parsed. This section may be used to emit errors if the condition is used in an improper context.

If this section is included, you must also [`continue`](./#continue) if the effect was parsed successfully.

{% hint style="info" %}
Local variables created in this section are copied by-value to other sections.

{% code-tabs %}
{% code-tabs-item title="example.sk" %}
```text
condition example:
  parse:
    set {_test} to 1
  check:
    # {_test} always starts at 1 here
    add 1 to {_test}
    # 2 is always broadcast
    broadcast "%{_test}%"
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endhint %}

### Section `check`

<commit_msg>GitBook: [master] one page modified<commit_after># Conditions

{% tabs %}
{% tab title="With one pattern" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] condition <pattern>:
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}

{% tab title="With multiple patterns" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] condition:
  patterns:
    # patterns, one per line
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}

{% tab title="Property condition" %}
{% code-tabs %}
{% code-tabs-item title="Syntax" %}
```text
[local] <skript type> property condition <pattern>:
  parse:
    # code, optional
  check:
    # code, required
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endtab %}
{% endtabs %}

### Flag `local`

Specifying that a condition is `local` makes the condition only usable from within the script that it is defined in. This allows you to create condition that do not interfere with conditions from other addons or scripts.

{% hint style="info" %}
Local conditions are guaranteed to be parsed before other custom conditions, but not necessarily before conditions from other addons.
{% endhint %}

### Section `parse`

Code in this section is executed whenever the condition is parsed. This section may be used to emit errors if the condition is used in an improper context.

If this section is included, you must also [`continue`](./#continue) if the effect was parsed successfully.

{% hint style="info" %}
Local variables created in this section are copied by-value to other sections.

{% code-tabs %}
{% code-tabs-item title="example.sk" %}
```text
condition example:
  parse:
    set {_test} to 1
  check:
    # {_test} always starts at 1 here
    add 1 to {_test}
    # 2 is always broadcast
    broadcast "%{_test}%"
```
{% endcode-tabs-item %}
{% endcode-tabs %}
{% endhint %}

### Section `check`

Code in this section is executed whenever the condition is checked. This section must [`continue`](./#continue) if the condition is met. \(The section may exit normally if the condition fails.\)




{'fraction_non_alphanumeric': 0.13866348448687352, 'fraction_numerical': 0.0019093078758949881, 'mean_word_length': 3.8619489559164735, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2545451', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1206, 'n_words': 479}