# Event Filters

Some events have built-in filters that restrict when an event is triggered depending on certain circumstances. One example of this is the `on right-click:` event.

{% code overflow="wrap" lineNumbers="true" %}

```python
on right-click:
  if type of player's tool = diamond:
    send "Ooh, shiny!" to player
```

{% endcode %}

While this code will work, it will be triggered for all right-click events, when it's only needed in some. To optimise this, we can add a filter to the event:

{% code overflow="wrap" lineNumbers="true" %}

```python
on right-click with diamond:
  send "Ooh, shiny!" to player
```

{% endcode %}

Using filters like this also usually allows one to cut-back on indentation, as well as remove a line.

{% hint style="info" %}
You can see if an event accepts a filter when you check the syntax on the documentation.

For links to the documentation, see the [Resources page](/syntask/resources.md).
{% endhint %}

Some common examples of events with filters include:

* `on (right|left)(-| )click with %item type%:`
* `on (right|left)(-| )click on %block type%:`
  * (Note that items use `with`, while blocks use `on`. These are not interchangeable.)
* `on (death|damage) of %entity type%:`
* `on (mine|break|place) of %block type%:`
* `on craft of %item type%:`


---

# 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://x8ight.gitbook.io/syntask/limiters/filters/event-filters.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.
