CS skipping over *if statements?

I’m having trouble with my code skipping over what I assume are valid *if statements in my script.

The error I’m getting is: that the code goes down a path it shouldn’t. It’s running without error messages, but ending up in the wrong place.

My code looks like this:

*if ((pronoun = "he/him") and (romance = "male"))
  ENDING 1 HERE. 
  *ending
*elseif ((pronoun = "she/her") and (romance = "female")) 
  Ending 2 Here. 
  *ending
*else
  Ending 3 Here. 
  *ending

Even though pronoun is set to “he/him” and romance is set to “male” (I checked on the stats page), I end up at Ending 3.

Am I missing something pretty major here?

Is the variable “pronoun” supposed to actually be “he/him” (with the slash and all) or the condition should be reached if its any of these?

Because then you would need to make it:

*if (((pronoun = "he") or (pronoun = "him")) and (romance = "male"))

Might also place:

${pronoun} | ${romance}

*page_break

On the line above this if check so the game shows in the screen the value of those variables; this should tell you exactly what they are before it gets to the *if and you can see if it’s correct or not. Since you’ve said that ending 3 is always reached, the problem is likely something wrong in the conditions of the first *if and the following *elseif.

1 Like

Sorry, was in a class. It’s supposed to be “he/him” with the slash. I can try the variable check you suggested when I get home. I’ll let you know how that goes.

Does the variable work in other places?

It displays fine on the stats page or when using ${pronouns}, but no if statements using it work.

Wait, the if statement in your first post uses pronoun, not pronouns. That would do it.

If the variable would not exist an error would pop up.

It might be the /.
Could you try replacing it with just one word?

1 Like

Yep that’s what I was about to say. I avoid using characters like / in variables as I remember a long time ago I did that and it messed the coding up (Which makes sense when you think about it.) Use letters and numbers only to be sure. (Haven’t tried that specific combo though, but I suspect it might be the problem.)

Edit: Maybe just make a little test file rather than changing your entire work (unless there’s not much to change) and see if that works as soon as you take the / out.

1 Like

I renamed the string variable to not have any characters and that didn’t work. The script is still running me to the *else statements automatically.

Ok, can you show more of your code? Show us the *create for the “pronoun” variable and what is shown in the game with the {pronoun} and {romance} right before the *if check?

Yeah, the create part looks like this:

*create pronoun "undetermined"

Later in the startup scene it’s set like so:

*set pronoun "hehim"

then in the “ending” scene I use ${pronoun} and sure enough it displays hehim.

And did you change the *if to account for it?

*if ((pronoun = "hehim") and (romance = "male"))
.
.
.

And what is the value of ${romance}?

Yep. The if reads correctly, and ${romance} pops up as male.

Just an aside, if you want the pronoun variable to display either “he” or “him” but not “hehim”, I would recommend looking into multireplace.

Thanks. I might look into that if I have the time. Right now I’m trying to get the paths to work right before I mess with text and what appears to the reader. ; u ; I’m very very new to all of this.

Well, it’d be good to see your entire code then; something else might be going wrong.

If you want to place it somewhere, I recommend on the website below and then you give us the link so we can take a better look at what is going on.

Oh boy. Okay. Please be aware that the code is not efficient in the least bit.

Depending on what you test with:
Did you delete the cookies for CS?
I have similar issues when testing from the index file when i did not clear the cookies after changing the scenefile

Also if you haven’t already, run quick and random test though it. There may be something wrong in the code somewhere that it can pick up for you.

Cleared the cookies and that didn’t work. Here’s the “ending” file. Again sorry for it being a hot mess.

NOOB CODE