# Set Mes Macro

### Signature

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

### Description

Used before functions like [mes](mes "mention") and [a-ask-1ff](a-ask-1ff "mention") 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** 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](update-mes-macro "mention") 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.

```c
//dialog (ebp section 2)
{dialog 0}
Moogle
{speed:0}You have {macro:0,8,1,1} Gil.
{/dialog}

//location script (ebp section 0)
script 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.
  }
}
```

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

```c
//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}

//location script (ebp section 0)
script 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.
  }
}
```
