# Changing gender - how to do it elegantly?

**URL:** <https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170>\
**Category:** ChoiceScript Help\
**Created:** [February 28, 2013, 1:41pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170 "2013-02-28T13:41:10Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![StanTheMan](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@StanTheMan](https://forum.choiceofgames.com/u/StanTheMan)\
**Post date:** [February 28, 2013, 4:35pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/21 "2013-02-28T16:35:03Z")

</div>

Well, there IS that issue - I was gonna write a separate question. Assuming I use the Boolean option, and I wanted the stat screen to display “Man” or “Woman,” then how would I go about it?

If it’s impossible, then, I’d do it as a string and be done with it, as suggested earlier. Which seems easier to code, for me, at my current, ah, coding “level.”

---

<div class="post-metadata">

**Author:** ![FcA](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fca/32/432_2.png) [@FcA](https://forum.choiceofgames.com/u/FcA)\
**Post date:** [February 28, 2013, 4:58pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/22 "2013-02-28T16:58:35Z")

</div>

@CJW It’s mostly for aesthetic purpose in my case. I figure if I could define the gender in only one place and throw them back as end-user info (mostly because how do you explain a boolean variable to the reader-player to understand that they are playing a male/female?), plus I like my linecount to be as anorexic as possible, it then eliminates the reason for further using a separate variable. But @StanTheMan, I’d look at the direction where I want to go with the setup. Boolean for gender is definitely nice and quick assuming you only deal with male-female context. I only go string for the display.

edit  
Wait a sec… is it possible to retract values (“male”) from boolean and slap them onto the screen with the $! thing? You’re giving me ideas…

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [February 28, 2013, 5:39pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/23 "2013-02-28T17:39:14Z")

</div>

@FcA No… Haha.

It means if you write everything in lowercase in a variable, for e.g. \*set name “alice”  
And then you type ${name} - it’ll print “alice” - right?

But if you put an exclamation mark in front of it, it’ll capitalize the first letter, and print “Alice” $!{name}

Two exclamation marks capitalizes the whole word.

---

<div class="post-metadata">

**Author:** ![FcA](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fca/32/432_2.png) [@FcA](https://forum.choiceofgames.com/u/FcA)\
**Post date:** [February 28, 2013, 6:11pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/24 "2013-02-28T18:11:07Z")

</div>

That I know. Been using them a little here and there for other purpose, I just thought… oh nevermind. Lol.

Anyway, just strikes me that a cute workaround may be doable.

Setup 1. Gender in string, display directly.

`*set gender "male"` and `*set gender "female"` where applicable, then in your stats txt, `${gender}` or, yes, `$!{gender}` if feeling like it.

Setup 2. Gender in boolean, display with a condition check.

`*set male true` and `*set male false` where applicable, then in the stats txt,

```

*if (male)
  Male
*if !(male)
  Female

```

---

<div class="post-metadata">

**Author:** ![RETowers](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/retowers/32/21477_2.png) [@RETowers](https://forum.choiceofgames.com/u/RETowers)\
**Post date:** [March 2, 2013, 2:32pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/25 "2013-03-02T14:32:19Z")

</div>

@CJW A few days late, but reading a post about gender, I can’t help but laugh when variable I see listed is `blue_ball`. I can’t be the only person childish enough to have started laughing from seeing that.

@StanTheMan As FcA mentioned, it can be done with variables. Another thing you can do (if you prefer to avoid the confusion of using 'not equal to’s) is to have two variables: _male_ and _female_ (and possibly a third _non\_gendered_ if you want to give the option), so that rather than:

```

*if male
  Male
*if (male = false)
  Female

```

You’ll end up using the more natural:

```

*if male
  Male
*if female
  Female

```

---

<div class="post-metadata">

**Author:** ![P\_Tigras](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/p_tigras/32/626_2.png) [@P\_Tigras](https://forum.choiceofgames.com/u/P_Tigras)\
**Post date:** [March 2, 2013, 4:50pm UTC](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170/26 "2013-03-02T16:50:45Z")

</div>

BTW, as an alternative to

```

if (male=false)
  Female stuff

```

there is always:

```

if not(male)
  Female stuff

```

This way readability is improved while maintaining the improved efficiency of a single boolean variable.

The bigger your game gets, the more important it becomes to keep your code as efficient as possible to reduce the number of bugs you have to find and fix. Every new variable you create is one more that you’ll have to properly initialize and maintain. Every new variable you create is also one more potential source of bugs. In this particular case you may end up with weird situations like (male=true and female=true), or (male=false and female=false) that are completely impossible when you use a single boolean variable.

This is just a small hassle when we’re dealing with variables that are static (stay the same) through the entirety of the game, like gender, but it can turn into a —huge headache— when the variable values can change during the game. It’s thus best to learn good coding habits and stick to them, even for the small stuff. You’ll thank yourself later as your game nears completion.

The single boolean variable does not need to be ‘male’ of course. It could just as easily be ‘female’. I’d only recommend the two variable scenario for gender for those who specifically desire to allow for transgendered protagonists.

[Previous page](https://forum.choiceofgames.com/t/changing-gender-how-to-do-it-elegantly/1170.md?page=1)
