# \*If statement skipped over regardless of outcome

**URL:** <https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965>\
**Category:** ChoiceScript Help\
**Created:** [January 11, 2021, 8:13pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965 "2021-01-11T20:13:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:13pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/1 "2021-01-11T20:13:00Z")

</div>

This issue is likely very easy to solve and I’m just too dumb to figure it out from the tutorials, but here it is!

I can’t tell if I’m not creating the variable right, if I’m writing the \*if statement wrong or if I can’t use an \*if statement outside of \*choice.

When I run the game it simply doesn’t show anything for that part, not even the place \*goto is supposed to lead to, it’s as if the \*if statement doesn’t even exit

![image](https://global.discourse-cdn.com/choiceofgames/original/3X/c/3/c333f7798c95119055f4dd122236a4e03deb5336.png)

---

<div class="post-metadata">

**Author:** ![Jayffel](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jayffel/32/121784_2.png) [@Jayffel](https://forum.choiceofgames.com/u/Jayffel)\
**Post date:** [January 11, 2021, 8:16pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/2 "2021-01-11T20:16:59Z")

</div>

IIRC \*create only works at the top of the startup file. Maybe moving it there will change things, if it’s not there already? It might be skipping both because the game doesn’t realize “eye” is a variable, so it doesn’t know what to do with the if/else statement.

edit: You could also use a \*temp instead of \*create, but I’m not sure if that would have to be at the top of the file it’s used in or not.

---

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:20pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/3 "2021-01-11T20:20:23Z")

</div>

Neither of the two possible solutions you’ve suggested worked :c

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [January 11, 2021, 8:22pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/4 "2021-01-11T20:22:39Z")

</div>

How are you testing the files? what’s the output? is there any error?

---

<div class="post-metadata">

**Author:** ![Sinnie](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Sinnie](https://forum.choiceofgames.com/u/Sinnie)\
**Post date:** [January 11, 2021, 8:26pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/5 "2021-01-11T20:26:57Z")

</div>

This works for me. I just created a new startup.txt and wrote the following.

If eye = 1 then it will print both statements in both labels - but it definitely works as the ‘its alive’ / ‘its dead’ lines print correctly

```
*create eye 0

*if eye = 1
    It's alive
    *goto soldierpercpass
*else
    It's dead
    *goto cantseeeye

*label soldierpercpass
Eye is 1

*label cantseeeye
Eye is 0

```

---

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:28pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/6 "2021-01-11T20:28:04Z")

</div>

Code:

```
*create eye 1

*script changeBackgroundColor("black")
*comment-end
*comment-start Race
You find yourself on a large stage, blinded by the lights beaming down on you and deafened by the excited screams of the audience before you.

*label race

You are not alone. There are several other people on the stage with you, along with strange, floating creatures. Their bodies seem to be made out of a single, large eye surrounded by flesh and flailing tentacles.
They are watching you with intensity, unblinking.

*if eye = 1
	It's alive!
	*goto soldierpercpass
*else
	It's dead!
	*goto cantseeeye

They are seeing a...

```

Output:

```
You find yourself on a large stage, blinded by the lights beaming down on you and deafened by the excited screams of the audience before you.

You are not alone. There are several other people on the stage with you, along with strange, floating creatures. Their bodies seem to be made out of a single, large eye surrounded by flesh and flailing tentacles. They are watching you with intensity, unblinking.

They are seeing a...

```

I’m using a local server as described in the tutorial. After I save the edits of the .txt file I refresh the browser. Works fine with any edits I make, so the issue isn’t there. There is no error for this.

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [January 11, 2021, 8:33pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/7 "2021-01-11T20:33:56Z")

</div>

Please put your code surrounded by 3 of this ` at the beginning and 3 at the end. or click the \</\> on top of where you write the reply so we can see the code properly.

---

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:37pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/8 "2021-01-11T20:37:26Z")

</div>

It looks like it should work, but copy pasting your code into my startup file still isn’t doing it :c

---

<div class="post-metadata">

**Author:** ![Sinnie](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Sinnie](https://forum.choiceofgames.com/u/Sinnie)\
**Post date:** [January 11, 2021, 8:38pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/9 "2021-01-11T20:38:54Z")

</div>

Are the labels for soldierpercpass and cantseeeye in the same file?

---

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:39pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/10 "2021-01-11T20:39:06Z")

</div>

Yes

---

<div class="post-metadata">

**Author:** ![Freja](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/freja/32/110753_2.png) [@Freja](https://forum.choiceofgames.com/u/Freja)\
**Post date:** [January 11, 2021, 8:41pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/11 "2021-01-11T20:41:59Z")

</div>

I don’t know if it will help you, but I hope it does.  
I recommend you to:  
\*create eye 0

Then when/if the character has the eye:  
\*set eye +1

With that, I think your coding with \*if and \*else should work.

Good luck!

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [January 11, 2021, 8:44pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/12 "2021-01-11T20:44:27Z")

</div>

Have you tried to use another method to try it like the randomtest or quicktest or something else?

---

<div class="post-metadata">

**Author:** ![Netty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/netty/32/91854_2.png) [@Netty](https://forum.choiceofgames.com/u/Netty)\
**Post date:** [January 11, 2021, 8:44pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/13 "2021-01-11T20:44:32Z")

</div>

Huh, it looks like there was an issue with the local server, the updates I was making weren’t going through anymore. I restarted it and now it seems to work. Thank you, everyone!

---

<div class="post-metadata">

**Author:** ![Sinnie](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Sinnie](https://forum.choiceofgames.com/u/Sinnie)\
**Post date:** [January 11, 2021, 8:44pm UTC](https://forum.choiceofgames.com/t/if-statement-skipped-over-regardless-of-outcome/92965/14 "2021-01-11T20:44:40Z")

</div>

I just copied and pasted your code into CSIDE and altered it by adding the two labels to the bottom. Output below:

```
*create eye 1

*script changeBackgroundColor("black")
*comment-end
*comment-start Race
You find yourself on a large stage, blinded by the lights beaming down on you and deafened by the excited screams of the audience before you.

*label race

You are not alone. There are several other people on the stage with you, along with strange, floating creatures. Their bodies seem to be made out of a single, large eye surrounded by flesh and flailing tentacles.
They are watching you with intensity, unblinking.

*if eye = 1
	It's alive!
	*goto soldierpercpass
*else
	It's dead!
	*goto cantseeeye

They are seeing a...

*label soldierpercpass
Eye is 1

*label cantseeeye
Eye is 0

```

Output:

```
You find yourself on a large stage, blinded by the lights beaming down on you and deafened by the excited screams of the audience before you.

You are not alone. There are several other people on the stage with you, along with strange, floating creatures. Their bodies seem to be made out of a single, large eye surrounded by flesh and flailing tentacles. They are watching you with intensity, unblinking.

It's alive! Eye is 1

Eye is 0

```

Looks right to me - it skips over the ‘They are seeing a…’ line (as the \*goto skips it).  
Then it displays both Eye is 1 and Eye is 0 because I didn’t use an \*if on the label bits as it isn’t needed for this test.

Can you try copy and pasting my above code into a blank file and seeing what happens.
