Code Error: no selectable options

Hi, as I’m still really new to learning to code my game so I have no idea where I have to fix the name input. Beforehand I just let the player write their own name but realised some people like pre-set options so I’ve tried putting it as so… I’ve muddled something up!

Can anyone help? Thanks in advance! :slight_smile:

The error I’m getting is: line 1352 of prologue: No selectable options

My code looks like this: (pre-warning it’s probably messy I am a baby cside user)

*choice
#Select a name.
*goto name_preset
#Input a name.
Please input your chosen Name
*goto input_name
*label input_name
*input_text pc_name
*if (pc_name = “”)
" . . . "
You can’t just leave it blank-not now.
*goto input_name
*label name_preset
*fake_choice
*if (pc_gender = “female”)
#Lilith
*set pc_name “Lilith”
*goto name_confirm
#Clarice.
*set pc_name “Clarice”
*goto name_confirm
*elseif (pc_gender = “male”)
#Leo
*set pc_name “Leo”
*goto name_confirm
#C
*set pc_name “C”
*goto name_confirm
*elseif (pc_gender = “nonbinary”)
#Lief
*set pc_name “Lief”
*goto name_confirm
#Cyrus
*set pc_name “Cyrus”
*goto name_confirm
*goto name_confirm
*label name_confirm
“My name is ${pc_name},” you say and before ${c_he} has a chance to respond Caelis glances upward, eyes tracking something you can’t quite see through the smoke.

Example
*commend
    Indent

Could you include the proper indentations as they appear in your game within a code block, please? It will be easier to help. (:

1 Like

Oops I see it copied over weird, one moment!
(aha this took me a moment, let me know if this is correct?) Also uh I moved some things around after posting this because I am impatiently trying to solve it myself so not sure if that is bad–

*choice
    #Select a name.
        *goto name_preset
    #Input a name.
        Please input your chosen Name 
        *goto input_name
*label name_preset            
*fake_choice
    *if (pc_gender = "female")
        #Lilith
            *set pc_name "Lilith"
            *goto name_confirm
        #Clarice.
            *set pc_name "Clarice"
            *goto name_confirm
    *elseif (pc_gender = "male") 
        #Leo
            *set pc_name "Leo"
            *goto name_confirm
        #C
            *set pc_name "C"
            *goto name_confirm
    *elseif (pc_gender = "nonbinary")
        #Lief
            *set pc_name "Lief"
            *goto name_confirm
        #Cyrus
            *set pc_name "Cyrus"
            *goto name_confirm
 
*input_text pc_name
*if (pc_name = "")
     " . . . "
     You can't just leave it blank-not now.
     *goto input_name
*label name_confirm
"My name is ${pc_name}," you say and before ${c_he} has a chance to respond Caelis glances upward, eyes tracking something you can’t quite see through the smoke.

What’s the code that lets you set your gender?

Assuming that line 1352 is the name picking choice, it may be that there’s a situation where the player’s gender is neither female, male nor nonbinary (e.g. if the pc_gender flag was spelled differently, like as “non-binary”, when set)

1 Like

An addendum to this - in this context, I don’t think you even need / should make the code ‘elseif’ for the male and nonbinary branches. I believe simple clean ‘if’ statements for each individual choice work fine when within a choice like this.

2 Likes
How do you identify?
*choice
    #Woman
        *set pc_gender "woman"
        *goto pronoun_select
    #Man
        *set pc_gender "man"
        *goto pronoun_select
    #Nonbinary
        *set pc_gender "nonbinary"
        *goto pronoun_select
    #Prefer not to say
        *set pc_gender "unspecified"
        *goto pronoun_select

Facepalming. I haven’t yet edited this portion from an earlier stage so safe to assume you are correct I think– honestly CSide is like learning a foreign language to me. :sweat_smile:

1 Like

No worries at all - Yeah, the lack of choices available to an “unspecified” pc_gender would defo break it I think.

And no worries - ChoiceScript is literally a (programming) language, so it’s no surprise that you feel that way! Great skill to learn though :slight_smile:

2 Likes

Also depending on what you *create it as, quicktest may end up giving you issues because it assumes that initial value is going to be used, I believe. (I could remember wrong though.)

Sidenote: your restructured code is missing *label input_name!

1 Like

Yeah, personally, I think the if/elseif structure is fine, but you probably want to structure it with an else at the end to serve as a fallback (e.g., if female/elseif male/elseif nonbinary/else) so the automated tests don’t flag it.

ChoiceScript doesn’t really like it when every option in a choice is conditional. You might ensure it’s impossible to not qualify for any of the options (though as you’ve seen, it’s very easy to make a mistake), but ChoiceScript’s automated tests don’t know that and might fail you.

Also, minor thing, but ChoiceScript will already not let you leave an *input_text field without inputting anything. No need to check yourself.

2 Likes

Oh, additionally: you could put an unconditional “I want to input my own after all” (or the like) that leads to the inputting at the end of the list; that would be both a QOL feature so that people who don’t like the available options aren’t forced to load a save to backtrack, and ensure there is at least one available option always.

2 Likes

Looking at your code, I notice you’re using elseif in the choice, which is likely where the error is. Change it this…(I’ve also added the missing label input_name that @LiliArch pointed out earlier)

*choice
    #Select a name.
        *goto name_preset
    #Input a name.
        Please input your chosen Name 
        *goto input_name
*label name_preset            
*choice
    *if (pc_gender = "female")
        #Lilith
            *set pc_name "Lilith"
            *goto name_confirm
    *if (pc_gender = "female")
        #Clarice.
            *set pc_name "Clarice"
            *goto name_confirm
    *if (pc_gender = "male") 
        #Leo
            *set pc_name "Leo"
            *goto name_confirm
    *if (pc_gender = "male") 
        #C
            *set pc_name "C"
            *goto name_confirm
    *if (pc_gender = "nonbinary")
        #Lief
            *set pc_name "Lief"
            *goto name_confirm
    *if (pc_gender = "nonbinary")
        #Cyrus
            *set pc_name "Cyrus"
            *goto name_confirm
 
*label input_name
*input_text pc_name
*if (pc_name = "")
     " . . . "
     You can't just leave it blank-not now.
     *goto input_name
*label name_confirm
"My name is ${pc_name}," you say and before ${c_he} has a chance to respond Caelis glances upward, eyes tracking something you can’t quite see through the smoke.


That’s not the error. Using *elseif in choices is completely valid ChoiceScript.

1 Like

Sorry, I’ve never seen someone use elseif and elses in the actual choice coding in the way they’ve put them in the above code. I’ve only ever seen it the way I suggested or like this;

*if (one)
    *choice
        #Option A.
            *goto next_scene
        #Option B.
            *goto next_scene
*elseif (two)
    *choice
        #Option C.
            *goto next_scene
        #Option D.
            *goto next_scene
*else
    *choice
        #Option E.
            *goto next_scene
        #Option F.
            *goto next_scene
3 Likes

So….since you have specific names for each gender…. you can also use multireplace. You just have to make a variable for it. In the example, “gender_num” is 1 for female, 2 for male, and 3 for nonbinary.

*fake_choice
  #@{gender_num Anna|Adam|Alex}
    *set name "@{gender_num Anna|Adam|Alex}"
  #@{gender_num Helen|Heath|Harper}
    *set name "@{gender_num Helen|Heath|Harper}"
  #@{gender_num Sophie|Shaun|Sloan}
    *set name "@{gender_num Sophie|Shaun|Sloan}"
  #Something else...
    *gosub enter_name

That said! I do agree with other posters to keep your in-choice conditionals to just *if statements or to separate the choice into three, each kept within an IF block (or within an if/elseif/else set of blocks).

2 Likes

Something worth noting: It’s easy to imagine your code going wrong because you had a fourth option, “unspecified,” that wasn’t given any options. But even if you’d only had three options, m/f/nb, the auto-testers don’t know that. If all your options are behind *if or *elseif gates, QT will flake out because the game has nowhere to go if there’s some fourth (or fifth, or sixth…) option.

*else is the solution, the catchall that covers everything not explicitly mentioned in earlier conditions. QT steers you toward using *else to avoid precisely the kind of bug your code would have had – you forgot that “unspecified” was possible, and so someone who’d chosen that would have the game crash here because there are no unspecified names.

You could also get around this by just offering a final choice that isn’t gated. In this case, instead of having two successive choices – one a binary of preset v enter-your-own, and then a list of presets – you could take the reader straight to a single choice of name. Have a whole bunch of name choices gated by *if or *elseif conditions, and then for your final option, #Input a name of my choice.

That way the reader will always have something to choose even if you’ve forgotten to give presets for one of your gender categories, and the auto-testers won’t crash.

4 Likes

Wow everyone is so helpful here thank you so much I’m not gonna lie I’m quite stubborn so I’ve been very hard at work trying to get a hand of the coding by just mass searching the forum and checking the wiki (I also have no idea how to random test) so I have been “testing” by doing individual run throughs of the game. so it’s a lot of skipping — I think it’s longer this way but it’s been working? :joy::rofl:)

ignore the ugly coding to the side bc it isn’t the best but I see the female two options I couldn’t see last night​:blue_heart:

Also is random testing a time saver?

:woman_dancing: currently doing a little happy dance :woman_dancing:

I do a lot of that too. But don’t neglect Quicktest or Randomtest if you hope to publish a game. Anything you submit to Hosted Games has to pass both, and it’s way easier to figure out early how to code in a way that passes the testers than it is to change a game’s worth of code at the end.

Randomtest can also be helpful in figuring out how hard it is to reach certain lines of code. That can help you find some nonobvious bugs; if RT hits it 0 times in 10,000 random playthroughs, check to see if it’s actually unreachable.

5 Likes

To run quicktest and randomtest in CSIDE you just need to right-click on the title of your game in the scenes & projects tab (the one where you have an eye next to the game name) and then select the Test Project option, both are in there.

5 Likes

Note that the above only works in the desktop versions of CSIDE. It looks like you’re using the web/Dropbox version, which can’t run automated tests.

3 Likes

Thanks..I’ve used the desktop version for so long I’ve forgotten what the web version is like.

3 Likes