Random Colours In Messages
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?
<>Message: 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", set the "Single Variable" to Randomize, which is then "Set Equal To" a "Random Number Between" 1 and 19. (The colours are based on the 20 colours in the current System Set. Zero is the "default" colour, but we won't use it in this example.)
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, which I may expand upon in a later entry. 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.
The emboldened part 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 adhered to. This will also work in RMXP and RMVX, but the default colours will need to be added to in RMXP via script (in Window_Base under the text_color method).
2 Comments So Far:
very cool way to take advantage of the the ability to play with the text, I hadn't thought of this, thanks!
Yeah, it is quite interesting. Amazing what comes from boredom sometimes.
Post a Comment