Changing gender - how to do it elegantly?

Again, another question for folks here. Writing a choicescript game which will let the player be either gender in the game. Naturally, this will change gender pronouns, names, and other things in the game. I’ve finished the intro/first chapter, and the only way I could figure out to do gender flipping properly all-that-stuff-wise was to write one version for the mens, another for the ladies, and then set up the *goto variables to put the player along one path or another based on their gender attribute.

But I wonder…is there a cleaner way to do it throughout the game? I mean, I know the memory size isn’t an issue for a text file, so I don’t mind just copypasting and editing the file; isn’t that hard once the main text is written, after all. Just…IS there a better way for a permanent solution for the gender text switching issue? Or do I have it the right way already?

I only ask once, then I set up:
Name
MC_hisher
MC_heshe
MC_himher

Eg
{Name} took out {MC_hisher} umbrella so ${MC_heshe} wouldn’t get wet.

@StanTheMan

As long as you don’t *line_break it’s fine:


The ball bounced down the aisle.
*if (ball_blue)
 The ball was blue.
*if (ball_blue != true)
 The ball was red.

The resulting text would print out as a whole line:

The ball bounced down the aisle. The ball was blue.

OR

The ball bounced down the aisle. The ball was red.

Edit:
forget what I wrote… Lucid’s solution is much better.

@StanTheMan
The method @Lucid mentioned will absolutely save you a lot of trouble. Use it for anything gender-dependent that you use often (like titles or pronouns). Anything else that changes according to gender you can change on a case-by-case basis by using *ifs for that specific section. That way, you can just use one main body of text.

Interesting Lucid…does that sort of thing work for ALL pronouns, like, I have a world where the major NPCs will often be the same gender of the player (i.e., if the player chooses male, then they’ll mostly be male; if female, then female). What I want is to not only change it for the main character, but for others around him/her, based on their earlier chosen gender. Does that make sense?

Or, does what you posted work for that too, and I’m just dense?

CS_Closet, can you explain that a little? You can use *if in the text? If so, how? I’m not visualizing it…

thats useful I do separate scenes men women but almost all the stuff is diferent so I don’t know if the *if will be useful for me but I learn how to do it so thanks :slight_smile:

In my game, I just use {he}, {his}, etc for the MC pronouns depending on the player’s choice of sex, {xhe}, {xhis} for NPCs of the MC’s preferred sex – which may of course be the same as the MC’s sex – and {zhe}, {zhis} for NPCs of the non-preferred sex (or second preferred sex, if you choose to be bi).

Male pronouns not because I see any of the characters as male, but because the “him/his” distinction isn’t captured by “her/her” in English.

If I need to write something else gender-specific that doesn’t come up frequently enough to require a stat, I use *ifs like CS_Closet suggests:

"The NPC stroked ${xhis}
*if xhe = "he"
  beard
*if xhe = "she"
  chin
thoughtfully."

@StanTheMan
If you have a section of text that would change depending on gender, you just switch it out with a couple of *if statements:


You stop by the
*if gender = "male"
    barber shop to check if Old Hank has time for you today.
*if gender = "female"
    beauty salon to see if your regular stylist is in.
It doesn't look like you'll be able to get anything done immediately, though.

With that sort of *if statement, you won’t have to repeat similar blocks of text over again, but it’s still customized to the player.

Thanks for that CJW!

Now, more pointed help: it was mentioned above that I’d type:

MC_hisher
MC_heshe
MC_himher

in the stats file, which is fine, no worries.

My problem is, I’m a little fuzzy on how that works. What I mean is, how do I set it up so this works (i.e. my player chooses their gender (I assume a Boolean true/false), and have it so the correct gender shows). In terms of the actual coding. Just want to make sure I get it right.

Thanks all, so far. Very insightful stuff.

Ah, I see…MC is main character. Got it. I AM dense. :wink:

Havenstone, CS, much more clear, thank you.

Are you a boy or girl?
*choice
#Boy
------*set MC_hisher “his”
------*set MC_heshe “he”
------*set MC_himher “him”
------*goto next
#Girl
------*set MC_hisher “her”
------*set MC_heshe “she”
------*set MC_himher “her”
------*goto next
*label next

Yup, works for any character that you want alternate sexes for.

1 Like

Specifically talking about gender I’d prefer not to have my gender variable as boolean although later on during checks you could filter it through with boolean if you like. If you go with *if (sex="Male"), a check for the opposite can be put as *if (sex!="Male") as some have posted above… I think. It looks neater.

Re determining an NPC’s gender based on MC’s, it’s also a quick check. In a certain part in my work I introduce an NPC who would be a woman if you play as male, but a man if you play female. It goes like


*if (sex="Male")
  *set npc_att1 "she"
  *set npc_att2 "her"
*if (sex="Female")
  *set npc_att1 "he"
  *set npc_att2 "his"

… and the attributes can be as elaborate as you need them to be. Is that what you were asking?

Using a boolean is considered the best coding practice, because it’s much harder to make a typing error.

For e.g. if you have:


*set gender="male"
*if (gender = "mal")
 Do something

Nothing will happen here, but you won’t get an error either - so in more complex situations you can cause yourself some hard-to-find bugs (I know in this case it’d be somewhat obvious).

However if you use a boolean:


*set gender_male tru  
*comment (false being female)
*if (gender = true)
 Do something

This will produce an error, as you’re not allowed to set a boolean to anything but true or false.

Even if you made a typo this way:


*temp boolean_a
*set boolean_a true
*if (dog = truee)
 do something

Again you’d get an error, because ‘truee’ isn’t a reserved word, the game would look for a variable (which it wouldn’t find), making it an immediately noticeable error.

There’s no “right” or “wrong” way to do this of course, but I thought I’d share that for anyone who might have an interest in programming outside of choicescript.

@Lucid, thank you! Exactly what I was looking for. I’ll have to recode the intro but that’ll be easy, and it’ll help the next scene (which I started writing now).

@FcA: yeah, that’s what I was going for as well - same issue you mention; I’ve NPCs that’ll be different genders based on the player’s gender. Thank you very much!

Give me something to do for the next few days!

@CJW: aye, it’s interesting! I’ll have a think then; I only thought of a Boolean because, well, it’s a Boolean choice in this game, as it were. If it’s cleaner for coding and debugging, then, maybe I’ll give it a whirl.

Thanks all!

I agree that a Boolean is good for the male/female choice. For reference, here’s what the gendered bits of my mygame.js folder look like (kuria/kurios is the form of noble title you get from the Imperial authorities, milady/milord in your homeland):


    ,female: true
    ,femalepref: true
    ,malepref: false
    ,kuria: "kuria"
    ,milady: "milady"
    ,he: "she"
    ,him: "her"
    ,his: "her"
    ,hers: "hers"
    ,woman: "woman"
    ,xhe: "she"
    ,xhis: "her"
    ,xhim: "her"
    ,xkuria: "kuria"
    ,xmilady: "milady"
    ,zhe: "he"
    ,zhis: "his"
    ,zhim: "him"
    ,zkuria: "kurios"
    ,zmilady: "milord"

The choice of sex comes when your father addresses you as either…


*choice
  #"... son."
    *set female false
    *set kuria "kurios"
    *set milady "milord"
    *set he "he"
    *set his "his"
    *set him "him"
    *set hers "his"
    *set woman "man"
    *goto whathappened
  #"... daughter."
    *goto whathappened

And the first chance you get to find someone attractive sets the sex for the other two:


  *choice
    #He is small and lean, but his thoughtful, fearless demeanor is striking in a helot.
      *set xhe "he"
      *set xhis "his"
      *set xhim "him"
      *set xkuria "kurios"
      *set xmilady "milord"
      *set femalepref false
      *set malepref true
      *set zhe "she"
      *set zhis "her"
      *set zhim "her"
      *set zkuria "kuria"
      *set zmilady "milady"
      *goto sermon
    #She is muscular and sunburned from field work, but even a noble accustomed to
tradesmen's smooth-skinned daughters would be drawn to her charm and intellect.
      *goto sermon

At a later point, there’s a further choice where you can confirm that your character is attracted to the “zhe” sex too, at which point “femalepref” and “malepref” would both be set to true.

@StanTheMan No problem, glad to help.
A little thing maybe to think about is how the variables are gonna be used further than mere containing if the MC is a she or he, so to speak. In my build’s case, I need to return the value to the stat screen for display, hence it needs to be string. I even have to use capital for the first letter… lol. In any other case, maybe you would want to give a more flexible options for your players. If being a transgender is relevant to your content, then maybe you can’t go boolean? Bug trapping in @CJW’s theory is very interesting though.

@FcA - You mention needing to use a capital letter, have you tried using the capitalization syntax?


*temp name
*set name "john"
${name} --> Will print "john"
$!{name} --> Will print "John"
$!!{name} --> Will print "JOHN"

As for booleans being limited to two options, that’s true (not false mauahhaha) - you can use multiple booleans or start using strings, like I said there’s no “right” or “wrong”, they both work, it’s merely considered good practice to use booleans for the above reasons.

I’m sure you all double check your spelling anyway :smiley: