Help with choices

I’m trying to make this so that the player gets a choice and then their statistics are adjusted based on their skill level. However, I keep getting error codes related to either "expected a #option” in the ‘Set’ lines” or not being able to “fall out of a choice”

Can anyone help? Thanks in advance!!

For some people, their jobs come easily to them. Others find every day to be a struggle for success. You…
*choice
#Quickly discovered that you’re a natural at your work. Even from the beginning, you excelled at what you do.
*If skill = “Medicine”
*Set Mental_acuity +5
*Set social_Intellegence +5
*goto hobbies

*If skill = “Weapon Mastery”
*Set perception +5
*Set agility +5
*goto hobbies

John

I’m not sure what this looks like in your IDE, but make sure you’ve got your indents correct.

For some people, their jobs come easily to them. Others find every day to be a struggle for success. You…
*choice
    #Quickly discovered that you’re a natural at your work. Even from the beginning, you excelled at what you do.
        *If skill = “Medicine”
            *Set Mental_acuity +5
            *Set social_Intellegence +5
            *goto hobbies

        *If skill = “Weapon Mastery”
            *Set perception +5
            *Set agility +5
            *goto hobbies

Thanks!

That did fix that issue, but then I get this for the option line (the line with the #)…

“It is illegal to fall out of a *choice statement. You must ***goto or *finish before the end of the indented block.”

I have a *goto line at the end; what am I doing wrong?

Thanks again!

John

“Invalid

Try this out:

The goto needs to not be in the conditional. Even though you’ll always hit a goto via your conditionals, Choice script is fussy that way.

I appreciate that, but where to I put it, then?

I did switch to elseif, thanks much for the suggestion! It didn’t seem to solve the problem, but I think it prevented the next problem I was going to run into.

Maybe the only possible skills you can have at this point in the game are Medicine or Weapon Mastery – but the autotester bots don’t know that. They’ll just see a choice where, if your skill is anything else, the code goes nowhere.

You could use myeraland’s suggestion, having an “else” that will never be reached. (The “else” here is crucial to passing QT/RT, because it’s concerned about the hypothetical other skills.) Or, like Zodac01 implied, you could just have a single *goto hobbies indented to the same level as your *ifs. That way, the code will goto that label for either skill and for any other possible skill, which will satisfy QT/RT.

*choice
    #Quickly discovered that you’re a natural at your work. Even from the beginning, you excelled at what you do.
        *If skill = “Medicine”
            *Set Mental_acuity +5
            *Set social_Intellegence +5
        *If skill = “Weapon Mastery”
            *Set perception +5
            *Set agility +5
        *goto hobbies

Or you could use *else differently. If these are the only two possible skills, and you can’t have them both (which from your use of gotos was I assume your intent):

*choice
    #Quickly discovered that you’re a natural at your work. Even from the beginning, you excelled at what you do.
        *If skill = “Medicine”
            *Set Mental_acuity +5
            *Set social_Intellegence +5
            *goto hobbies
        *else
            *comment this has to be Weapon Mastery
            *Set perception +5
            *Set agility +5
            *goto hobbies

It sounds like you tried to do this using *elseif skill = "Weapon Mastery" instead of else… but that wouldn’t tell the code where it should go for a player with neither skill. Only *else covers all other possible options, and thus satisfies QT/RT that you haven’t left room for a bug where the game has nowhere to go.

1 Like

Thank you all!

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.