# CS skipping over \*if statements?

**URL:** <https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357>\
**Category:** ChoiceScript Help\
**Created:** [October 23, 2018, 10:03pm UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357 "2018-10-23T22:03:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 23, 2018, 10:03pm UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/1 "2018-10-23T22:03:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![GoldenSilver](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/goldensilver/32/110153_2.png) [@GoldenSilver](https://forum.choiceofgames.com/u/GoldenSilver)\
**Post date:** [October 23, 2018, 10:14pm UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/2 "2018-10-23T22:14:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 23, 2018, 11:57pm UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/3 "2018-10-23T23:57:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MeltingPenguins](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/meltingpenguins/32/255855_2.png) [@MeltingPenguins](https://forum.choiceofgames.com/u/MeltingPenguins)\
**Post date:** [October 24, 2018, 12:05am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/4 "2018-10-24T00:05:14Z")

</div>

Does the variable work in other places?

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 12:15am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/5 "2018-10-24T00:15:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![James\_Marsh](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James\_Marsh](https://forum.choiceofgames.com/u/James_Marsh)\
**Post date:** [October 24, 2018, 12:18am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/6 "2018-10-24T00:18:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MeltingPenguins](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/meltingpenguins/32/255855_2.png) [@MeltingPenguins](https://forum.choiceofgames.com/u/MeltingPenguins)\
**Post date:** [October 24, 2018, 12:20am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/7 "2018-10-24T00:20:51Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Jacic](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jacic/32/7061_2.png) [@Jacic](https://forum.choiceofgames.com/u/Jacic)\
**Post date:** [October 24, 2018, 12:28am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/8 "2018-10-24T00:28:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 12:42am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/9 "2018-10-24T00:42:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GoldenSilver](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/goldensilver/32/110153_2.png) [@GoldenSilver](https://forum.choiceofgames.com/u/GoldenSilver)\
**Post date:** [October 24, 2018, 12:44am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/10 "2018-10-24T00:44:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 12:53am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/11 "2018-10-24T00:53:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GoldenSilver](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/goldensilver/32/110153_2.png) [@GoldenSilver](https://forum.choiceofgames.com/u/GoldenSilver)\
**Post date:** [October 24, 2018, 12:58am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/12 "2018-10-24T00:58:29Z")

</div>

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

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

```

And what is the value of ${romance}?

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 12:59am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/13 "2018-10-24T00:59:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carlos.R](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/carlos.r/32/75837_2.png) [@Carlos.R](https://forum.choiceofgames.com/u/Carlos.R)\
**Post date:** [October 24, 2018, 1:00am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/14 "2018-10-24T01:00:43Z")

</div>

Just an aside, if you want the pronoun variable to display either “he” or “him” but not “hehim”, I would recommend looking into [multireplace](http://choicescriptdev.wikia.com/wiki/Multireplace).

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 1:03am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/15 "2018-10-24T01:03:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GoldenSilver](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/goldensilver/32/110153_2.png) [@GoldenSilver](https://forum.choiceofgames.com/u/GoldenSilver)\
**Post date:** [October 24, 2018, 1:04am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/16 "2018-10-24T01:04:07Z")

</div>

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.

> **[Pastebin.com - #1 paste tool since 2002!](https://pastebin.com/)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 1:05am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/17 "2018-10-24T01:05:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MeltingPenguins](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/meltingpenguins/32/255855_2.png) [@MeltingPenguins](https://forum.choiceofgames.com/u/MeltingPenguins)\
**Post date:** [October 24, 2018, 1:07am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/18 "2018-10-24T01:07:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jacic](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jacic/32/7061_2.png) [@Jacic](https://forum.choiceofgames.com/u/Jacic)\
**Post date:** [October 24, 2018, 1:12am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/19 "2018-10-24T01:12:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![localgoblin](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@localgoblin](https://forum.choiceofgames.com/u/localgoblin)\
**Post date:** [October 24, 2018, 1:12am UTC](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357/20 "2018-10-24T01:12:27Z")

</div>

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

[NOOB CODE](https://pastebin.com/T7NUKDHQ)

[Next page](https://forum.choiceofgames.com/t/cs-skipping-over-if-statements/45357.md?page=2)
