How do you code choices within choices

#1

Hi everyone,

So I just started using ChoiceScript today and I’ve already given myself a massive headache. How do I create choice options within choice options. I tend to alright for the first one when I’m just building on top of the example code but after that the whole thing comes crashing down and I find myself in a sea of error messages.

Thanks in advance,

Confusedwriter

#2

It’s just a matter of getting the indentation correct. That said, for exactly this reason, I’d personally avoid nesting more than two choices deep. Just use *goto with *label to jump to the next choice(s).

5 Likes
#3

Generally I would just go

*choice
    #Option   
          Text
          *choice
              #Option
              #Option
              #Option
    #Option
    #Option

And so on.

2 Likes
#5

I have literally never nested choices. I just use gotos and send it to different labels for the next choice. But no one accused me of being a code wizard.

3 Likes
#6

If you’re using non-default text editor, there should be option to turn whitespace marking visible; are you using default notepad?

#7

@Latraytray i feel like the indentation in your example is off. Shouldn’t the orginal, non-nested #options be at the same indentation of the first #option in the *choice?

1 Like
#8

Lol yeah. I wrote it on mobile and forgot to double check I changed the spacing for everything

#9

@hustlertwo is smart. Be like Hustlertwo :grin:
(Seriously though I nest choices all the time, and have also forgotten how many times I’ve had to go looking for an error or misdirect because I’ve ended up nesting a dozen different choices at different levels. Using a goto keeps things simpler.)

If you do want to nest, I personally recommend using tabs over spaces. They’re bigger and easier to see where you’ve made a mistake instead of looking for the place where you put 2 instead of 3 spaces. (But that’s up to you.)

4 Likes
#10

A way to avoid nesting is to use *gosubs. If the nesting gets too big you can just use a *gosub and put nested stuff there and simply come back to where you were.

I use this a lot recently and keep them all stored at the bottom of the file. This is very useful for dialogue which has a lot of nesting due to responses to specific options taken by the player and usually long blocks of text. Makes it more organized and less of an eyesore especially when the indentation gets messy.

1 Like
#11

@Szaal Yes, I’m using the default