How to Set Text Color In gameMessage.add Script

Hi there!

I've started playing around with the scripting capabilities of MV and am stumped with trying to change the color of the text that I display when using
Code:
gameMessage.add("some text");
.

I know I'm probably overlooking something. Thanks in advance.
You're forgetting the $

Code:
$gameMessage

As for text color, the game message window uses "drawTextEx" to draw the text, meaning it will reset the font every time it is called, but it can read data inside the string and perform operations based on that. To change the text color, you need to use this inside the text (here's the format):

Code:
\C[n]

where n = the color.
Nearly! It's a script call so you'll need to \escape all backslashes, e.g.
Code:
$gameMessage.add("\\C[14]Yellow text! \\C[0]OK back to normal now.");
Ah, thank you so much! I was forgetting to escape the backslash for the change color command.
Ah, thank you so much! I was forgetting to escape the backslash for the change color command.
Anything in Script - if it requires an apostrophe or a Backslash, it should be prefixed by another backslash (with the exception of forced Newlines)...
Such as:
Code:
$gameMessage.add('\\C[17]\\N[1]\\C[0]:\nI\'m Loving The Sunshine!.');

I'm not sure about you, but I'm also a big fan of having the character's name on the first line with their text underneath, and to mirror this programmatically I do the following:
Code:
$gameMessage.add('\\C[17]\\N[1]\\C[0]:\n' +
  'I\'m Loving The Sunshine!.'
);

It may appear messy at first, but if you consider the first line will never need to change, it may be easier to see at a glance what the context of your messagebox might be 🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-set-text-color-in-gamemessage-add-script.115199/