Help with error: Invalid expression, couldn't extract another token: ${cpoccupation}

Ok I’m guessing that choicescript doesn’t like variables used in *set sequences but just thought I’d ask in case there was something else wrong.

So what I was trying to do, was put a specific save point at endings in my book if people want to go back to a branch without having to start again. Instead of having to make a separate ending page for each finish (there’s quite a few of them). As it will sometimes need variables reset, I thought I’d do this:

(On the endpoint page)
*set namecheckpoint “First meeting with the fairy in your room”

*set cpoccupation “Mundane Member Of Society”
*set gotocheckpoint “declinefairy”
*goto_scene ending

(And on the ending page)
Would you like to play again?

    #Restore from last checkpoint: ${namecheckpoint}
        *set occupation ${cpoccupation}
        *goto_scene ${gotocheckpoint}
    #Restart from the beginning    

The error I get is:
Invalid expression, couldn’t extract another token: ${cpoccupation}

Otherwise I guess I have the choice page at the ending with specific variables listed instead of using the ${ } command.

(*edit the spaces are right, for some reason they look like they’re gone in the post).

There’s a savepoint system implemented in choicescript (I just learned this myself).

This should help- because it loads your save with all the stats the way they are at the point where you *show_password. And then where you *restore_password, it will take you to the exact point you *show_password with that password that you use in the *restore_password. It won’t work if you close your browser, but it is a lot better than nothing. :slight_smile: Hope it helps.

@Jacic Select the code in the message and click the </> looking button. That should get the indentations back in.

1 Like

I think it should be: *set occupation cpoccupation

Right now it’s: *set occupation ${cpoccupation}
which gets changed into: *set occupation Mundane Member Of Society (note the lack of quotation marks).

What you want is: *set occupation cpoccupation
which gets changed into: *set occupation “Mundane Member Of Society”

Doesn’t seem to like that either. Now I get:
Non-existent variable ‘cpoccupation’

Thanks for pointing that out :smile:
I was hoping to put something in that could stay as save points when it’s released but if it’s going to be to hard I can take them out or code it differently.

Make sure you *create cpoccupation.