Quicktest Error: "It is illegal to fall out of a *choice statement"

Can anyone tell what I did wrong here?

When I use quicktest and randomtest it said ‘It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block.’ But when I manually test it myself it got no error on the same part. Can anyone figure what is wrong with my code below?

It always got error at the #Brown hair and other, but not #Black hair.

*choice
  #Skull structure that is a standard of healthy human. 
    As you look at your face, you reminded yourself that you are a human. The most...

    You look at your human face and its...
    *set race1 true
    *set stren + 2
    *set agil +2
    *set intel + 2
    *set char + 2
    *choice
      #Black hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short black"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail black"
          *goto eyec
      #Brown hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short brown"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail brown"
          *goto eyec
      #Blonde hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short blonde"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail blonde"
          *goto eyec
      #Red hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short red"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail red"
          *goto eyec
1 Like

There was just a thread about this. :slightly_smiling: [RESOLVED] Problem with *if and *elseif - #11 by Havenstone

The problem is that if both male and female were false, the game would crash. QT will pick that up as a bug.

Use else instead of elseif and it’ll work.

1 Like

Quick test ‘cheats’ when it tests. It doesn’t track what it’s doing, it just checks for typos (mostly). When it gets to an *if, it doesn’t remember what it’s done, it just tests both sides.

*In this case, you shouldn’t be use *elseif you should just use else. Otherwise, when quicktest gets to the male if, it tests both sides (male = true and male != true). Then when it gets to the next part, it does the same thing again. (Female = true Female != true).

ty all, for answering me, I am looking forward to share this game with you guys.

I got another error, same kind of error. But there are no *if or *elseif in this one.

  #Act
    *choice
      #Talk to it
        You have a pleasant conversation
        *set like + 10
        *goto good
      #Wait...
        Okay, why?
        *goto stun_check
      #Nevermind
        *goto fight
1 Like

I’m having the same problem. An error shows up when there’s nothing wrong. It’s annoying as hell. :rage: Hope you get an answer.

1 Like

I have seen this same error when my *choice statements lead to *gosub. I tried adding *finish after (on the next line) and that seemed to resolve the error. Maybe try that and see if it works for you? :slight_smile:

Check the line number (main reason to get Notepad++ over Notepad if you’re on windows), because that’s not the entire code, and there’s no way for someone to guess where your errors are.

I know even with a line # it’s sometimes been non-obvious to me where the error was – IIRC, quicktest would list a line just above or below the offending block of code. But I was ultimately always able to figure out something that would make it go away.

This is what the one choice that is apparently being illegal looks like.

#"This is a choice that works fine when I play it, just not in quicktest."
     Blah blah blag bibbidy bloobidy blah. 
     Blah blah blah balahhhhhhh.

     Baggidy biggidy blah blah boo balah.
     *set something_something_something true
     *goto this_is_the_goto
     *finish

I changed the words but everything else is the same, including the use of underscores.
Also that goto does lead to a label. I’ve made sure multiple times. The spelling and all that is correct. I tried putting finish after the goto like TheBellaNotte suggested. I’m also using notepad ++ so I know exactly which choice has the problem. It still tells me I’m illegal. But I really think I’ve been a good citizen and followed all the laws. This is police brutality in my opinion. :sob:

1 Like

I found the way to fix it. Apparently the choices before this one that have *if (var = true) have to always end with *else or it will not pass. The number *if (var = 1) can end with *elseif though.

Also do anyone ever fix this bug?

@Dark_Jester: Ah, but that’s not the whole choice. What’s going on with the other #options? In my experience, the specific line QT highlights isn’t always the one that needs changing to fix the error.

Also, it wouldn’t cause this error, but you’d not reach the *finish after the *goto.

@555sarin, it’s not a bug. Read https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#fakes to see why.

I’ve checked all the other #options as well. They all end with goto or goto_scene. The scene exists, the labels that the choices goto exist. Everything is spelt correctly. It works when I play it. Nothing is wrong.

Also I put *finish after that goto because it fixed the problem for TheBellaNotte so I was seeing if it would work for me, unfortunately it didn’t. I know it would never reach the finish.

1 Like

Ah, got it. Are any of the choices conditional?

If you PM me the actual undisguised code, I promise not to steal any of your story or code – pinky swear. It’ll be available to the world once your game is tested and published, in any case… and it’s hard to diagnose where QT is getting flustered without seeing the actual code.

Oh yeah, I’ll send it to you if you want.

Since others may come to this thread and be interested to know what the solution ended up being, here’s an equivalent example (I don’t want to give away anything about @Dark_Jester’s actual game, so this is totally unrelated).

Imagine a game, Choice of the US Senator, where you have to choose between being Republican or Democrat – no third parties. And QT was giving you the error message for a line around this choice:

*choice
  #Make your base happy!
    *if republican
      You successfully shrink the government until it can be drowned in a bathtub-- all except the military, of course.
      *goto fallout_4
    *if democrat
      You buy every family in America a new national park (and hold pangender marriage ceremonies in them).
      *goto out_of_cash
  #Stick to the middle of the road.
      You are the image of fiscal responsibility and bipartisan consensus building.
      *goto lose_election
  #Depose the President and establish a parliamentary system.
    On the plus side, you can now pass laws with far less gridlock.
    *goto civil_war

The reason QuickTest would choke on this code is that QT doesn’t know the US has a two-party duopoly. So it checks to see what happens if a not-republican not-democrat chooses option 1… and the code crashes, because there’s no option for that. (Basically, the same problem highlighted with male/female in the CoG example – but it gets harder to see when there’s a lot more text involved, as there was in Dark_Jester’s choice).

A few things could be done to fix this. The one D_J used was to add

*else
  *finish

with the *else indented to the same depth as *if republican and *if democrat. That reassures QT that a not-republican not-democrat Senator can still keep playing the game after this choice – even if in the actual game, such a Senator would be impossible.

Alternately, changing *if democrat to *else or *if not(republican) should pass QuickTest too.

So if you’re getting this error, look to see where you’ve got an *if boolean1, *if boolean2 etc. in your choice, and make sure that there’s a way forward for the “not(boolean1) and not(boolean2)” reader.

3 Likes

In a bizarre coincidence, I happen to have updated the documentation yesterday to use “republican” and “democrat” instead of “male” and “female” in the official example.

Great minds think alike, I suppose!

2 Likes

Suppose that must be it. :slight_smile:

I got another error, plz look.

  #Drink Health Potion
    *if (hp_p <= 0)
      You don't have any right now. [You can always check the number of your potions. If you don't have any and still click this choice anyway you will lose a turn.]
      *goto stun_check
    *if (hp_p > 0)
      You drink a health potion.
      *set hp + 15
      *if (hp > max_hp)
        *set hp max_hp
        *goto stun_check
      *else
        *goto stun_check
  #Drink Energy Potion
    *if (energy_p <= 0)
      You don't have any right now.[You can always check the number of your potions. If you don't have any and still click this choice anyway you will lose a turn.]
      *goto stun_check
    *if (energy_p > 0)
      You drink an energy potion.
      *set energy + 10
      *if (energy > max_energy)
        *set energy max_energy
        *goto stun_check
      *else
        *goto stun_check
  #Nevermind
    *goto fight

It said only the ‘Drink Energy Potion’ is the one falling out. So why is the health potion isn’t falling out? And what did I do wrong here?

1 Like

If you swap your *if [stat] > 0 lines for *elses does that fix it?

1 Like