RPG Maker Times

Smile Game Builder and RPG Maker Tutorials, Plugins, Resources, Windowskins

Fun With Variables #1 – RM2K3

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:

<>Variable Oper:[0001:Randomize] Set, Rnd[1-19]<>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 thoughts on “Fun With Variables #1 – RM2K3

Categories

Archives

Follow me on Twitter

Sponsored Ad

Sponsored Ad


Hi-Tex House Pack Vol. 1

For Smile Game Builder

The Hi-Tex House Pack Vol. 1 contains 297 assets: 284 house wall terrains and 13 models. Get your copy for only $5!
© 2008-2018, Companion Wulf. All Rights Reserved.