Repeating "It is illegal to fall out of a *choice statement" error

Caveat: I am by no means a coding expert. I did run into this problem repeatedly in one particular scene of mine that had a lot of nested *choice sections, though. In my case, it was partly because I would edit that section, and then accidentally break something I couldn’t see in another part of the long, long chain of nested *choice.

It is definitely possible to nest choices instead of using *label, as long as the final choice in the chain has a proper *goto or *finish. I did it, to ten levels, with one of my games. I was finding I kept accidentally introducing bugs, though. Then it was very difficult to pinpoint the exact bug when I was falling out of choices because it was 2000 lines of ridiculously indented code, and had loops, and the problems weren’t necessarily anywhere near the line number of the error.

But something like this definitely works:


*choice
  #Red.
    *choice
      #Dancing shoes.
        *choice
          #Ballet.
            *finish
          #Tap.
            *finish
          #Jazz.
            *finish
      #Boiled sweets.
        *choice
          #Strawberry.
            *finish
          #Raspberry.
            *finish
          #Snozzberry.
            *finish
      #Fish.
        *choice
          #Saltwater.
            *finish
          #Freshwater.
            *finish
  #Green.
    *choice
      #Trees.
        *choice
          #Elm.
            *finish
          #Oak.
            *finish
          #Alder.
            *finish
      #Peppermints.
        *choice
          #Soft.
            *finish
          #Hard.
            *finish
          #Jelly.
            *finish
      #Myna birds.
        *choice
          #Wild.
            *finish
          #Pets.
            *finish

After trying to debug my crazy scene so many times, I did start using *label much more often.
For me, at least, I’ve found that if I keep my labels in the same order as the options I present, it makes it easier for me to figure out what’s going where. It’s also easier to look at when I come back a few months later in editing. That’s just my experience though, of course; I know other authors have much different approaches to organising complex code sequences.

I think, if I’m remembering correctly, that *fake_choice can also cause problems if there are more than a few layers of indentation (or the wrong kind of *if indentations), so that was usually one of my first checks.

I did have one falling-out bug that was really sticky, and I finally solved it with a step-through function using @CJW’s CSIDE, which I was beta testing. (And it should be out in the near future, and available to everyone! Yaaaay.) It turned out to be a sketchy *if sequence, like @Vendetta suggested.

I’d be curious what some of the authors here who have very complex code think of labels versus nested choices, or any thoughts on when to use what, or how many nested choices (if ever) are too many.

5 Likes