Need help with selectable_if

Hello I’m new to this but last year I literally quit coding choicesript because of an error i couldn’t fix after some time i came back and still i am unable to fix it i was wondering if anyone could help me out. I am working on a “mmo rpg” story and i already put a lot of effort into it already. Here is my code:

Growing up what interested you the most
*line_break
(Once you pick a sub class you cannot change it.)
*line_break
(you can choose 2 now and in the future you will be able to pick 2 more )
*choice
#minerals(mining)
*set mining +1
*gosub sc2
#trinkets (crafting)
*set crafting +1
*gosub sc2
#weapons (blacksmithing)
*set blsm +1
*gosub sc2
#fishing
*set fishing +1
*gosub sc2
#farming
*set farming +1
*gosub sc2
#animals (animal whisperer)
*set anwh +1
*gosub sc2
#science (alchemist)
*set alc +1
*gosub sc2
#gardening
*set gard +1
*gosub sc2
*label sc2
how else did you spend your free time?
*choice
*selectable_if (mining = 0) #minerals (minerals
*set mining +1
*gosub min
*selectable_if (crafting = 0) #trinkets (crafting)
*set crafting +1
*gosub craf
*selectable_if (blsm = 0) #weapons (blacksmithing)
*set blsm +1
*gosub blsm
*selectable_if (fishing = 0) #fishing
*set fishing +1
*gosub fish
*selectable_if (farming = 0) #farming
*set farming +1
*gosub farm
*selectable_if (anwh = 0) #animals (animal whisperer)
*set anwh +1
*gosub anwh
*selectable_if (alc = 0) #science (alchemist)
*set alc +1
*gosub alc
*selectable_if (gard = 0) #gardening
*set gard +1
*gosub gard

*label min
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label craf
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label blsm
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label fish
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label farm
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label anwh
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label alc
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

*label gard
Growing up ores always interested you. You would read books about the different materials across the nation. Part of you wanted to go out mining and find these ores.But you knew you were just a kid and it was dangerous.
*return

The error I keep receiving is line (with selectable_if) of startup: Non-existent command ‘selectable_if’

i used selectable_if during stat selection and it worked fine but when it came to selecting your “occupation” it didn’t work

I think your *gosub commands are used incorrectly.
You can try to change your code to something like this:

Growing up what interested you the most:
*choice
    #minerals(mining)
        *set mining +1
        *gosub 
        *goto sc2
*label sc2
how else did you spend your free time?
*choice
    *selectable_if (mining = 0) #minerals (minerals
        *set mining +1
        *gosub min
        *goto next_label

*label min
text for mining

labels for other skills

*label next_label

Since you are always adding the same amount of skill points and re-using text for skills, you could also do something like this:

*temp skills_chosen 0
Growing up what interested you the most:
*label choose_skill
*if skills_chosen >=2
   *goto next_label
*if skills_chosen = 1
    How else did you spend your free time?
*choice
    *selectable_if (mining = 0) #minerals (minerals
        *set skills_chosen +1
        *set mining +1
        Text about mining.
        *goto choose_skill
    *selectable_if (crafting = 0) #trinkets (crafting)
        *set skills_chosen +1
        *set crafting +1
        Text about ctafting.
        *goto choose_skill
*label next_label
2 Likes

Thanks for the heads up I will test it later. I assumed it would work since gosub worked for stat selection

What I think is happening here:

  1. The player selects the 1st skill;
  2. The program adds a skill point, sees *gosub command and sends you to *label sc2 (but not to labels with skill texts);
  3. The player sees the choice where you select the 2nd skill;
  4. *selectable_if is working fine at this point, so the player can select the next skill;
  5. The program sees *gosub command, goes to skill description;
  6. The program returns to the point right after *gosub command, but doesn’t see a *goto command and has no directions;
  7. The program goes to the next line of code instead, and it has *selectable_if;
  8. The program can’t recognize *selectable_if command without *choice (or *fake_choice) command before it - and it can’t see *choice after it gosubbed and returned;
  9. The program is confused and sends you the error message about *selectable_if - but the real problem was incorrect *gosub/*return usage.

Firstly, you need to format your code using the button with the sign that looks like this: </> Otherwise, you could have indentation errors and it would be impossible for us to see them, or help you solve them.

Secondly, what you have here is a *choice menu where the options don’t end in a *goto command. Te *gosub command doesn’t serve the same purpose, which means that after completing the subroutine, the code doesn’t know what line it needs to go to next.

If you fix this and still have an error, come back and post your (formatted) code and we’ll try again.

2 Likes