Update Mes Macro

Signature

void updatemesmacro(int windowId, int macroId); //id:0x01a9

Description

Used after the Set Mes Macro function to update a macro of the currently opened window instead of the next one.

It's usually used when you want to refresh a variable in a dialogue while its still open.

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, it will overwrite the properties of the current one.

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.

Examples

A Moogle that allows the player to adjust their current Gil.

//dialog (ebp section 2)
{dialog 0}
{speed:0}Moogle
You have {macro:0,8,1,1} Gil.
Press {btn:triangle} and {btn3:confirm} to adjust it.
{/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.
    while ((pad() & get_pad_cancel()) == 0) //loop until user presses cancel.
    {
        //amount increase/decreases faster based on how long a button was hold.
        if (pad() == 0)
        {
          amount = 0; //reset amount if no button was hold.
        }
        else if ((pad() == get_pad_ok() && havegill() < 99999999))
        {
          amount = amount + (1 + (havegill() / 100));
          addgill(amount); //add gil
        }
        else if ((pad() == 0x1000 && havegill() > 0))
        {
          amount = amount + (1 + (havegill() / 100));
          subgill(amount ); //remove gil
        }
        setmesmacro(0, 0, 0, havegill()); //set new value of gil macro.
        updatemesmacro(0, 0); //update gil macro.
        wait(1);
    }
    mesclose(0); //close dialog window.

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

Notes

Opening a window results in all its macros to be read and then cleared for the next time its opened. This function works by setting the macros of the next opened window, but then using those macros to update the ones of the current window. The small downside of this is that the macros are not cleared when the window is closed. So if the next window also has a macro that wasn't properly set, it will have the values from the last opened window. This is a very rare case though and should almost never happen.

Last updated