# Actions

## Overview

Actions are what defines what any given statement in a script should do.&#x20;

&#x20;The following code displays a very simple example of an action that just does something when applied (advancing through the game) and something else when reverted (rolling back through the game). It will match all statements that start with `myaction`, for example:

```javascript
'myaction'
'myaction something'
'myaction one two three'
```

```javascript
class MyAction extends Monogatari.Action {

    static matchString ([action]) {
        return action === 'myaction';
    }

    constructor ([myaction, ...args]) {
        super ();
    }
    
    apply () {
        // Do something
    }
    
    revert () {
        // Do something
    }
}

MyAction.id = 'MyAction';
```

Now that we have our action class, we need to register it in Monogatari so it knows it exists:

```javascript
monogatari.registerAction (MyAction);
```


---

# 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://developers.monogatari.io/documentation/develop/building-blocks/actions.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.
