MZ Returning JS in Message Core Macro [VisuStella]

Hello,

I'm using VisuStella Message Core plugin for RPG Maker MZ, and I'm trying to use Text Code Replacements to create macros for stats display.

For instance, I want to be able to write Restores \HP[500] in item description and have this result :
1598676613782.png


I can do that by writing Restores \c[18]500 \i[84]HP\c but I want to automatize the process. So I'm using Message Core Macros.

Here is my code.


1598676347404.png


However, the macros \c[] and \i are normalized this way, and the text is not colored, nor the icon is displayed. Instead, \c[18] and \i[84] are written.

How can I avoid normalizing these macros ?
Backslashes get converted to escape characters (ASCII 0x1b) before conversion, I'm guessing that's what the problem is here. Try this return line instead:
JavaScript:
return '\x1bc[18]' + count + '\x1bi[84]' + hpname;
The same approach is needed if you want to store a text code as a string in a variable, for example. 🙂
Backslashes get converted to escape characters (ASCII 0x1b) before conversion, I'm guessing that's what the problem is here. Try this return line instead:
JavaScript:
return '\x1bc[18]' + count + '\x1bi[84]' + hpname;
The same approach is needed if you want to store a text code as a string in a variable, for example. 🙂

Works fine ! Thank you !

Original thread: https://forums.rpgmakerweb.com/threads/returning-js-in-message-core-macro-visustella.126359/