I was bored! What can I say? So I started playing around and decided to have some fun with Variables! And why not? Better than advanced algebraic equations, which I was never any good at anyway!
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:
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, 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:
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 thoughts on“Fun With Variables #1 – RM2K3“
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.
You must log in to post a comment.