Gender interpolation in Flash

As a developer, I can’t help but deconstruct any game I end up playing. RPGs are a special fascination of mine, and I’ve often wondered how script writers handle games where the player can choose the main character’s gender. There are so many factors to consider beyond simply replacing occurrences of “his” with “her” and so forth; when you throw nicknames, honorifics, and insults into the mix along with all the various pronouns, there’s a huge number of variables to consider.

Today I was hanging out on the Flashpunk forums and the topic came up. Suddenly it occurred to me; you don’t need to have two defined lists of gender-appropriate tokens; just a consistent format for representing each possible option within the text itself.

For example, instead of doing this something like this:

Armitage: This is {var: player_name}. {gendered: subjective_uppercase}’s looking for a job.

The same could be written like this:

Armitage: This is {var: player_name}. {gendered: He/She}’s looking for a job.

It reads a lot better, for starters, and it avoids the need to maintain gendered tokens in a separate location than the script data. Granted, inline variables are harder to change in broad strokes at a later date, but on the other hand it’s harder to accidentally break lots of text by changing something global.

Here’s a little function I wrote to handle this in Flash. It’s not as flexible as the contrived example above, but it does what I set out to accomplish and I’m happy with it.

Let me know if this helps!