Random Colours In Messages (RM2K3/XP/VX/VXA)

What if, for whatever reason, you’d like the character’s name to be a different colour each time you speak to an NPC?

You’ll only need one variable (let’s call it Randomize) and one NPC event with two Command Events in it, thus:

<>Variable Oper:[0001:Randomize] Set, Rnd[1-19]<>Message: Heya, c[v[1]]n[1]c[0], how’s it going?
@>Control Variables: [0001:Randomize] = Random No. (1…7)
@>Text: Heya, c[v[1]]n[1]c[0], how’s it going?
@>Control Variables: [0001:Randomize] = Random No. (1…19)
@>Text: -, -,Normal, Bottom
:   :Heya, c[v[1]]n[1]c[0], how’s it going?
@>Variable Operation: [0001:Randomize] = Random No. (1…19)
@>Display Text: -, -,Normal, Down
:   :Heya, c[v[1]]n[1]c[0], how’s it going?
The first line sets up the random number for the colour. Under Variable Operations (RM2K3), (RMXP), Control Variables (RMVX) or Variable Operation (RMVXA), set the "Single Variable" to Randomize, which is then set to a random number between 1 and 19. (The colours are based on the 20 colours in the current System Set in RM2K3 or the windowskin colours in RMXP/VX/VXA. Zero is the "default".

The second displays a message with some "control characters" inserted. Control characters are letters or punctuation marks preceded by a backslash – there are 12 in total in RM2K3 and some additional ones in RMXP/VX/VXA definable through scripting. The ones we need are for inserting the colour (C), the name (N) and the variable containing the random number (V). The basic format, for example, would be N[1], which would display the name of the first Hero in the Database.

We’ll be using "nested" control characters (control characters contained within control characters) to display the name of the first Hero in the list (in the Database) in the randomly selected colour.

This is how the nested control characters fit together, split into four parts:

C[ V[1] ] N[1] C[0]
There are no spaces in between; it’s just easier to read. The variable control character is contained in the colour control character, generating the random colour each time the Hero talks to the NPC. The name of the Hero is then displayed in that colour. Finally, the text colour is set to its default colour so the rest of the text isn’t the same as the name.

Of course, this can be done with other things too, as long as the same format is followed. This will also work in RMXP/VX/VXA, but other colours can be added in via script (in Window_Base under the text_color method).