MV Plugin to play MEs via escape code in text.

Hello! I am looking for a plugin that will allow me to play a Music Effect specifically only ONCE when an escape code, like \me[argument] is inputted.

For example:

Code:
Text: "Unfortunately, it did not go as planned...\ME[Gag3]"

This will effectively play "Gag3" ME after the "..." types. Only when the Music Effect ends will the textbox close.

I searched all around the forums and internet for this, but only found this, which, unfortunately, I don't know how to edit properly (not enough understandable documentation to implement myself).

EDIT: There was something like this in Pokemon Essentials, but alas, that was for RGSS3 XP.
Hakuen Studio Message Actions should be able to do it. It's in their MV Museum bundle

the plugin linked is 1 way to add your custom escape character.
the music effect is probably a processCharacter, but you need to
target the file with volume, pitch, pan and use the filename to play it.

but I have no idea how the plugin works or how to use it with it.
With Cae_CustomEscCodes (the one you linked)...I think you could just copy the "Play SE" example from the plugin's help section and replace playSe with playMe.
Spoiler: play se example
"Process" type: 1) Play sound effect (no arguments) var se = {}; se.name = 'Bell1'; se.volume = 20; se.pitch = 100; se.pan = 0; AudioManager.playSe(se);
You might want something that lets you specify which ME to play, though, so...

In the Plugin Manager, double-click the Process Escape Codes parameter, then double-click a blank line to add a new entry. For that new entry, try this:
  • Code: ME
  • Arguments: ["Text"] (1 argument, the name of the ME)
  • Delimiters: [] (default)
  • Replacer:

    var me = {}; me.name = arguments[1]; me.volume = 20; me.pitch = 100; me.pan = 0; AudioManager.playMe(me);
Then I think you could use it in a message like \me[Mystery].

Or, like Aqua says, you could look for an alternative.
JavaScript:
(function () {
  const _Window_Message_processEscapeCharacter =
    Window_Message.prototype.processEscapeCharacter;
  Window_Message.prototype.processEscapeCharacter = function (code, textState) {
    if (code.toUpperCase() == "ME") {
      const name = /^\[([\w\-]+)\]/.exec(textState.text.slice(textState.index));
      AudioManager.playMe({ name: name[1], volume: 90, pitch: 100, pan: 0 });
      textState.index += name[0].length;
    } else {
      _Window_Message_processEscapeCharacter.call(this, code, textState);
    }
  };
})();

Try that out.

Original thread: https://forums.rpgmakerweb.com/threads/plugin-to-play-mes-via-escape-code-in-text.178114/