Simple *if , *else not working

I’m having trouble with a simple *if , *else

The error I’m getting is, I have create in startup a female true / male true and on the next page a choice to be male or female. This is working and sets female true or male true

I can’t see why this code is not working then, I get an expected operator was string

My code looks like this:

*if (male = true) "I told you I would get you here on time Sir."
*else "I told you I would get you here on time Ma'am."

I have tried *if (male)
I have tried *if (male = true) , If (female = true)
and so on

1 Like

Can you show the line where you created the male variable? Judging by the error you used *create male "" instead of *create male true.

1 Like

Thanks for your help, I simply needed a line after the *if statement (doh!)

It’s quite messy coding this actually!
I have to write if male true, then the correct text, then a goto because you cannot fall out of an if statement, then the whole rigmarole again for female

I have seen alternative coding using ${xxxx} but that is way above my pay grade lol

That does sound way complicated, if all that varies is how the character is addressed then ${address} is more concise and easier for you to read. Here’s a page explaining the topic on the ChoiceScript Wiki.


An alternative in stead of if / else is two *if statements.

*if (male = true)
I told you I would get you here on time, Sir.
*if (male = false)
I told you I would get you here on time, Ma’am.

Doing it this way, you dont have to worry about falling out of *if statements.


Would turning on implicit control flow help with that?

Nevertheless, I’m with @shario that if all you want to do is write “sir” or “madam”, a variable storing the character’s form of address is the way to go. Save the conditional structures for when there are significant differences to the text.

1 Like

This is nice, cheers!
It saves me the falling out issue and is within my mental capacity :crazy_face:

Implicit control yes,

Also… best piece of advice I got? make it a numeric value whilst adding options for he, him, his, So you can reference the numeric value (set 2 for female, set 1 for male, set 0 for non binary ) for easy if references, So starter should look like this.

*create gender 0
*create he “”
*create him “”
*create his “”

and the choice tends to be

#I’m male.
*set gender 1
*set he “he”
*set him “him”
*set his “his”

referenced by {he} in normal chat. E.g. {he}'s awake will come up either he’s awake, she’s awake, or (im currently fiddling around with non binary )

You can do a quick boolean run through if you need to be a male,
*if gender < 2
for a male, running this script, (w/out binary options)
*if gender > 1
for female (w/out binary options)

But i’ve found that this is only with choices that are gender specific, i’m sure there’s other uses for it.

1 Like

Great tips and advice from all, appreciated!

One thing I should have done in hindsight is not write the entire game and then subsequently go back and add gender options!

I have spent all day (and i mean ALL day!) typing *if male / * if female

This was my day off I could have gone to the pub!

:sweat_smile:I’m planning a full 2 weeks of ‘Adding a gender-neutral option’ when i’ve finished

1 Like

Let me know when you crack it and I can nick the code please! :grinning:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.