# Set Mes Macro

### Signature

```c
void setmesmacro(int windowId, int macroId, int macroType, int macroParameter); //id:0x01a8
```

### Description

Used before functions like [Mes](/the-insurgents-handbook/scripts/vm-call-targets/mes.md) and [A Ask 1FF](/the-insurgents-handbook/scripts/vm-call-targets/a-ask-1ff.md) to dynamically set parts of the dialogue of the next opened window.

A macro is a value defined in the ebp script which is then passed to a dialogue for display and even modification (e.g. [Numbox](/the-insurgents-handbook/text/text-tags/numbox.md) text tag).

### Arguments

#### Window Identifier

The window the dialogue will be displayed in.

There are a total of 8 windows (0 -> 7) that can be used to simultaneously display several dialogues, shapes (textures), etc. at the same time.

If a value of `-1` is passed, it will be changed to `0`.

If the window is already used before calling this function, the macros of the next opened window will be set instead. To update the ones of the currently opened window, use the [Update Mes Macro](/the-insurgents-handbook/scripts/vm-call-targets/update-mes-macro.md) function instead.

#### Macro Identifier

The macro identifier of the dialogue that will be displayed.

There are a total of 32 macros (0 -> 31) that can be used to simultaneously display several dynamically modified parts of a text at the same time.

If the dialogue contains a **Numbox** text tag, the following macros have to be properly set before the window is opened:

* Macro 29 must contain the total number of choices (e.g. 2).
* Macro 28 must contain the initially selected choice (e.g. 0).
* Macro 0 to x - 1 must contain the choices itself where as x is the total number of choices.

#### Macro Type

The type of the macro parameter.

There are a total of 16 macro types (0 -> 15) that can be used to describe the macro parameter.

Here is a list of which macro types are commonly used.

<table><thead><tr><th width="89">Type</th><th width="142">Name</th><th>Description</th></tr></thead><tbody><tr><td>0</td><td>Number</td><td>The parameter is just a number.</td></tr><tr><td>1</td><td>Content</td><td>The parameter is the name of content (e.g. 0 -> Potion).</td></tr><tr><td>3</td><td>Action</td><td>The parameter is the name of an action (e.g. 0 -> Cure).</td></tr><tr><td>4</td><td>Party Member</td><td>The parameter is the name of a party member (e.g. 0 -> Vaan).</td></tr><tr><td>5</td><td>Clan Rank</td><td>The parameter is a clan rank (e.g. 1 -> Moppet).</td></tr><tr><td>6</td><td>License</td><td>The parameter is the name of a license (e.g. 32 -> Swords 1).</td></tr></tbody></table>

If the dialogue contains a **Numbox** text tag, only the macro type **Number** is supported. All other types result in the selectable choices to be bugged.

#### Macro Parameter

The parameter of the macro.

Its purpose differs based on its type (number, content, ...).

### Examples

#### A Moogle that shows the player their current Gil.

{% code title="Dialog (ebp section 2)" %}

```
{dialog 0}
Moogle
{speed:0}You have {macro:0,8,1,1} Gil.
{/dialog}
```

{% endcode %}

{% code title="Script (ebp section 0)" %}

```c
actor moogle(6)
{
  //init, main and other functions.

  function talk(2)
  {
    //hide hp menu, disable user control, etc.

    setmesmacro(0, 0, 0, havegill()); //set current gil macro.
    amese(0, 0x1000000); //open dialog window.
    messync(0, 1); //close dialog window.

    //show hp menu, enable user control, etc.
  }
}
```

{% endcode %}

#### A Moogle that asks the player if they want 100 or 200 Gil.

{% code title="Dialog (ebp section 2)" %}

```
{dialog 0}
Moogle
{speed:0}How much Gil would you need, kupo?
Select amount: {numbox:3,1,1,1}Gil
{/dialog}
```

{% endcode %}

{% code title="Script (ebp section 0)" %}

```c
actor moogle(6)
{
  //init, main and other functions.

  function talk(2)
  {
    //hide hp menu, disable user control, etc.

    setmesmacro(0, 28, 0, 0); //set the initially selected choice (0 -> 200 gil).
    setmesmacro(0, 29, 0, 2); //set the total number of choices (2).
    setmesmacro(0, 0, 0, 100); //set the first choice (100).
    setmesmacro(0, 1, 0, 200); //set the second choice (200).
    gil = aaske(0, 0x01000000); //open dialog window and wait for user selection
    messync(0, 1); //close dialog window.
    addgill(gil); //add selected gil to player's inventory.

    //show hp menu, enable user control, etc.
  }
}
```

{% endcode %}


---

# 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://xeavin.gitbook.io/the-insurgents-handbook/scripts/vm-call-targets/set-mes-macro.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.
