Choicescript help, Error: "set variable does not exist"

So, I’m attempting to create a race selection screen, and my code looks like this:

"Race?"
*choice
    #Human
        *set race 1
        *goto withdraw
    #Elf
        *set race 2
        *goto withdraw
    #Dwarf
        *set race 3
        *goto withdraw
    #Orc
        *set race 4
        *goto withdraw
    #Halfling
        *set race 5
        *goto withdraw

“withdraw,” in this case, is another part of the character creation.
I keep getting “error, set variable does not exist,” but I don’t know where it comes from. I have this same problem with another bit of code I’m trying to implement, allowing a player to change their job:

After some digging, you manged to land your previous job offers.
*choice
    *if (startprofession != 1) #Work as a porter at the docks
        *if (strength < 20) 
        The work is hard, the hours are long, and the customers are rude and brutish, but you are paid reasonably well for your time. By the week's end, you've made a decent amount of gold, and put on a bit of muscle.
        *line_break
        +10 gold.
        *line_break
        +1 strength.
        *set money +10
        *set startprofession 1
        *set promotion 7
        *if (strength < 20) *set strength +1
    *if (startprofession != 2) #Work as an alchemist's assistant
        Your eccentric employer is demanding and tyrannical, though you are paid a reasonable amount. By the week's end, you've made a bit of gold and have picked up on a few choice bits of knowledge.
        *line_break
        +10 gold.
        *line_break
        +1 cunning.
        *set money +10
        *set startprofession 2
        *set promotion 7
        *if (cunning <20) *set cunning +1
    *if (startprofession != 3) #Work at the Bank of Ides
        You had never realized how mind-numbingly boring it was, dealing with customer after customer. However, by the end of the week, you're paid a reasonable sum and have picked up a few new ways to get people to like you.
        *line_break
        +10 gold.
        *line_break
        +1 charisma.
        *set money +10
        *set startprofession 3
        *set promotion 7
        *if (charisma < 20) *set charisma +1
    *if (startprofession != 4) #Work as a courier for the Exchange Office
        Your clients are demanding, and by the end of most days you are drenched with sweat and exhausted. However, at the end of the week, you've made a decent amount of gold and have built up your agility.
        *line_break
        +70 gold.
        *line_break
        +5 agility.
        *set money +10
        *set startprofession 4
        *set promotion 7
        *if (agility < 20) *set agility +1
    *if (startprofession != 5) #Work as a watchman at the lighthouse
        You spend your days gazing out to sea, hailing approaching ships at the lighthouse. The work is boring, but by the week's end you've made some gold and you've become more perceptive.
        *line_break
        +70 gold.
        *line_break
        +5 perception.
        *set money +10
        *set startprofession 5
        *set promotion 7
        *if (perception < 20) *set perception +1
    *if (startprofession != 6) #Who needs a job? Become a pickpocket.
        Picking pockets is harder than you expected, and that bruise on your back still hurts, but by the end of the week you've lifted a good bit of gold and picked up a few pickpocketing tricks.
        *line_break
        +70 gold.
        *line_break
        +5 subtlety.
        *set money +10
        *set startprofession 6
        *set promotion 7
        *if (subtlety < 20) *set subtlety +1

Any idea what I’m doing wrong here? Help would be appreciated.

Did you *create the variables you are using in your startup scene?

Also, knowing the line number of the error is helpful; it can often help shed light on the source of the bug.

1 Like

I did, create all of them. I’ve done code blocks just like this dozens of times before in this project, but those are the only two times this kind of error has popped up.

Which line is throwing up the error?

And the variables might possibly be case sensitive; did you check them for capitalisation or typos…oh, or is the race variable a number? If you created it as a boolean or string, that might also be the problem, possibly?

I already tried declaring race to a number, but it didn’t seem to help. Let me try again.

Right, so just to be sure I’m clear, in startup, you have something like *create race 0 and *create money 0?

And just in case, you’ve made sure to save before testing again? (I’ve done that and thought I hadn’t fixed a problem, when I had….)

Declared everything in startup, and I’m quite an obsessive saver because of Chronicler’s chance of random crashes.

Hm, right. Which line specifically is given in the error?

That’s the hard part, since it specifies line 359 in the html doc, but the compiled Chronicler html doc is a mess, and the individual “lines” aren’t clearly defined at all.

Can you open the file as a text document and then see what line the error corresponds to? I’m not familiar with Chronicler (other than knowing what it is), but are you testing via Firefox? That should give you the line number that would show up if you opened the scene in a text editor.