Storing Text in Variables for Player Pronoun Selection
Nick Palmer
by
Nick Palmer
on
March 5, 2022
March 5, 2022

Storing Text in Variables for Player Pronoun Selection

Storing Text in Variables for Player Pronoun Selection
by

Nick Palmer

on

March 5, 2022

A common theme in modern RPGs is letting the player themself decide who their character will be. From selecting their body, eye color, selecting their hairstyle, and even selecting what pronouns they use. Let's look at a way to make this even easier to create in your game.

To do this the standard way, some people will just have a conditional branch before any message that contains the player's pronoun, reference a variable, and then rewrite the line for every pronoun set you use.

This works. But what if I was to tell you there is an even easier way, and it relies on one little secret: You can store pretty much whatever you want into variables, not just numbers. So let's learn how to do it!

Pronoun Choice and English Pronoun Forms

First thing you need to do is set up a very basic Show Text to ask the question, and Show Choices to give your player the choice of pronouns they would like to use. I've gone with the variations of he/she/they. You can, of course, add more if you want to for your game.

The next thing we need to do is identify all the different pronoun variations for parts of speech. The English language uses 5: Subject, Object, Possessive, Possessive Pronoun, and Reflexive.

For the 3 selections I have, the matching pronouns are: he/him/his/his/himself, she/her/her/hers/herself, and they/them/their/theirs/themself.

What we want is to store each of these in variables so that we can call them using \V[n] in message boxes.

BUT... there is one more thing we have to think about. If the pronoun is being used at the beginning of a sentence, it needs to have the first letter capitalized. That means we need 10 variables here. In my project, I'm going to use 11-15 for the capitalized versions of Subject/Object/Possessive/Possessive Pronoun/Reflexive, and 16-20 for the lower case versions.

Two Ways to Store Text in Variables

So how do we store that? There are two ways we could do this. The first way is to use the script section of the Control Variables event command with the Script option to put in text. To put text into a variable, be sure to put “” around the text you want to enter. To put They into variable 11, you could do the following:

But, while you could use that method to put in all of them, using the Script Event Command lets us put in all ten variations at the same time. So, let's head to the 3rd tab of your Event Commands and select Script. To put text into a variable using the Script Event Command we are going to use this simple script call:

$gameVariables.setValue([Variable],[Value])

All you need to do is replace [Variable] with the number of the variable you want to set, and replace [Value] with what you want to set it to. Additionally, if you are going to store text, you need to put "" around the Value. For example, to store They into Variable 11, you would use the script call:

$gameVariables.setValue(11,"They")

In a single script call, you can put in all ten variations you need, so with just some copy pasting and replacing, you can do all the They variations really quickly. Your script command should look like this:

Then you can easily copy this and alter it for the He and She parts of the Show Choices, this should leave you with an event that looks like this:

Using Text Variables in Show Message

Now, every time you need to use a pronoun in a line for your player character, instead of branching and creating an entire new message for each variation, you can just match the part of speech and whether you need it capitalized or not, and substitute in the variable!

So this:

Becomes this:

And that is all you need! You can now give your player more options, and make those options easier on yourself to implement!

Extra Uses and Storing an Actor Name into a Variable

But that isn't the only way you can use storing Text in Variables. You can also use it for anything where the player can select something and you need that selection to be able to show up in text. In fact, you can even have your characters name something themselves, by using an extra actor, the input name command, and then using the script section of the Control Variables event command and using "Script: $gameActors.actor(n).name()", replacing the n with the Actor number.

For example, after having the character name the ship using the Name Input Command with Actor 5, you could use the Control Variable command above to store it into a variable.

(Note: technically you could do this without dumping it into a Variable, by just using the command for substituting the Actor name in a text box, but moving the data to a variable means that you can reuse that Actor for all text inputs necessary for your game (passwords, etc), without clogging up your Actor tab in the Database).

And now you know how to store text into variables!

Recommended Posts