Saving progress through restarts in ChoiceScript

Storing info can be done using *input_number or *input_text. Check out Guenevere’s save mechanic.

*input_text var_text
*input_number var_num 1 10

The above allows the player to input a number between 1 and 10 inclusive. Where you seek to randomise variable ‘var_num’ between 1 and 10, inclusive, use *rand :slight_smile:

*rand var_num 1 10

In both cases you can use *if to interpret the input:

*if var_num = 1
  Varied story text 1
*if var_num = 2
  Varied story text 2

Getting more complicated, you can store the data in a series of booleans. This is the equivalent of a ‘seed’, possibly comparable with the way that other games generate different maps in different playthroughs.

*rand var_num 1 3
*if var_num = 1
  *set story_path_1 true
*if var_num = 2
  *set story_path_2 true
*if var_num = 3
  *set story_path_3 true

*if story_path_1 = 1
  Varied story text 1
*if story_path_2 = 2
  Varied story text 2
*if story_path_3 = 3
  Varied story text 3

Or if you are a programmer, you can use choicescript to work out the length of a variable, or interpret a specific part of a variable. I don’t recommend this unless you are really well acquainted with CS (arguably it also doesn’t add much value).

*set choice_seed 12
Page 1 
*if choice_seed#1 = 1
  *choice
    #Go to the market.
    #Go to the castle.
*if choice_seed#1 = 2
  *choice
    #Go to the tournament.
    #Go to the prison.

Page 2 
*if choice_seed#2 = 1
  *choice
    #Talk to the squire.
    #Talk to the arms master.
*if choice_seed#2 = 2
  *choice
    #Talk to the stable girl.
    #Talk to the priest.

Well done, you finished the story! If you play again, inputting:

21

will give you a different story experience on your second read through.

Page 1 checks the first number of choice_seed. Page 2 checks the second number of choice_seed. The first playthrough, when choice_seed = 12, allows the reader to go to the market or the castle, then talk to the stable girl or talk to the priest.

After one playthrough you could give your reader a new seed code: ‘21’. Now when *input_num is used at the start of the game, you can vary significant parts of the story.

*input_number choice_seed 11 22

(This input-number allows either 11 or 12 or 21 or 22 to be inputted). The reader inputs the new code you gave them ‘21’

Now the reader is given the choice to go to the tournament, or go to the prison on page 1. Then on page 2, they have the choice to talk to the squire, or talk to the arms master.

Note: if you use this method you might just have given yourself twice as much story to write, but 85% of your players (who won’t reread), will never actually see it.

1 Like