Unsure how to use *choice

Is the line number on your error message the same as the choice you posted?
Maybe it’s getting caught up somewhere else?

Was about to say that. Always look at the line number it mentions first. (Someone it’ll be elsewhere but more likely that’s where the problem is and you can work the problem out more easily.)

2 Likes

You must missed this one #choice, hidden below the pile of hay.

Try to look for it.


And btw, if you encountered multiple problems, try to ask them in a single thread instead. You know, keep things tidy.

1 Like

Ok, so someone already gave me a solution to this, it didn’t seem to work!!

Code:

*choice
    #Male
        Ok.
        *set gender male
        *page_break
        *goto afterGender
    #Female
        Ok.
        *set gender female
        *page_break
        *goto afterGender

*label afterGender

Error message:

"It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block."

It should work like that, i cant see any problems. Also you don’t need to use *page_break after a choice as it does that automatically. Hope someone can help with that :slight_smile:

1 Like

Actually wondering if removing the *page_break will fix your problem for you! Give us an update when you can! :slight_smile:

2 Likes

Also, if your gender variable is a string variable, it wont recognise *set gender male . male should be “male” .

*choice
    #Male
        *set gender "male"
        *goto scene
    #female
        *set gender "female"
        *goto scene
    
*label scene

This should work. But the one you posted shouldn’t have been giving that error but non-existent variable error. So im not sure whats the problem there…

Also dont forget to create your variable first :slight_smile:

It’s probably that.
So maybe “male” an “female”. Assuming the startup variables are already made.
Edit: Nevermind, read the error message and it has nothing to do with that. I can only blame page_break.
Edit 2x: I tried creating variants of what you did, nope, no error messages at all. You might want to show us your startup variables.

1 Like

Yeah, page_break isn’t necessary, but inserting one before *goto has no effect at all and thus shouldn’t have any errors either.

1 Like

Ok, here’s my startup thingy:

*title [here]
*author [here]
*create strength "20"
*create stamina "20"
*create speed "20"
*create gender "0"
*create name "0"

*scene_list
  startup

Did removing *page_break help?
If not:

  1. Put the scenelist before the creates (iirc this might not be the source of the prob but might cause trouble down the line)
  2. Remove 0 from the create for gender. “” will do iirc.
  3. Check the indents
1 Like

Ok guys. I’m very new, so forgive me, but I’ve just discovered I was being an idiot.
The script BEFORE the gender was the one being wrong, NOT the gender script. Oh golly. I don’t know how I did that. Sorry guys~
:heart:

1 Like

Don’t worry.
Did you manage to fix the problem?

Also, on a note before, cause i think no one corrected that:
If you have flavor-text (like the ok) a page_break is okay.
In fact:
If you have flavor-text, a page_break might help with the flow of the story if the text is not part of the narrative as such.
Otherwise it’ll appear above the next text body

1 Like

Yes, I did fix the problem!
And thanks for the advice.

Btw, having all the variables as strings (“”)
might cause a problem in character development IMO. For example;

*choice
    #you train your body.
        *set strength +5

Probably wont work because its a string variable instead of a numeric one and might make it hard to code. Im not sure if you can change string variables like that and i couldnt try it as im not on PC but i think its gonna be like this. I will try it this evening and edit this post. Also i dont know if you can do *set strength “+5” for a string variable but i think it would change strength “20” to strength “+5” .

EDIT: I checked and it works perfectly well, so no problem :slight_smile:

Also please use the forum search feature to see if others have had similar problems you could learn from. (Spoilers: they have.) In particular, if you get an error message, searching or Googling for the words in your error message will often turn up helpful stuff.

That would help me, but I don’t know how to find a line number easily… Would I just have to count all the way to it? >.<
It’s number… 146, I think. Or 164.

Code using CSIDE–it should make lots of this easier, including finding line numbers and checking how your game looks as you write.

3 Likes

In most text editor, you can see the code line at the left-hand bar of the screen. They should look like this

1   ieeaayisaioosta
2   |t@$bkorsbkphs
3   rrrrrrrrrrrrrrr

And if there’s not a number I believe crtl/cmd + L lets you search for it in most programs.