Is this the easiest way? Why use THIS method?
Yes, as of 7/28/17 this is the easiest way to save progress for checkpoints in choice games listed anywhere on the forum. This method is preferable because it only uses a few lines of code, you can save a infinite number of variables and have an infinite number of saves at the same time. Also: This doesn’t require complicated stuff or javascript editing. It doesn’t use the *script command and should be 100% alright for publishing.
How do I do it?
It’s easy.
Step One
This method requires Twiger_Functions v0.7 or higher so go to this link You may either download it and move the twiger_function.txt file to your scenes folder or you can copy and paste it into a file named twiger_function.txt in your scenes folder.
Note1: This file also comes with the array functions. To learn about them, go here.
Note2: to update this file, you can copy the text from the link and then replace all the previous text. (copy the new version, go to your text editor, into the twiger_functions file press ctrl+a then ctrl+v)
Step Two
It startup.txt create the variable save_num
*create save_num ""
Step Three
Next you will want to create save variables like this:
*create save_1 ""
*create save_1b ""
You must create two variables in the startup.txt with the format save_[save name] and save_[save name]b In the example above, I named my save “1” but it can be anything, such as “213564” or “bubbles”
You can have as many saves as you want:
*create save_1 ""
*create save_1b ""
*create save_apple ""
*create save_appleb ""
*create save_death ""
*create save_deathb ""
etc
Step Four
Once you’re done with the first three steps, you can do this in any scene you want, wherever you want.
Doing this will save the variables listed. You may then change the variables all you want, but they will remain as what they were saved in the the save variable.
*set save_num 1
*set save_1 "~x~y~z"
*gosub_scene twiger_functions save
Note: This example would save the variables x, y, and z into the save named save_1 Keep in mind you must put a ~ in front of each variable name.
If you want to save the variables “health” “stamina” “coins” and “dragons” into your save named “playerdeath” you would do this:
*set save_num "playerdeath"
*set save_playerdeath "~health~stamina~coins~dragons"
*gosub_scene twiger_functions save
Note: the variables save_[save name] and save_num can be set whenever you want. If they already list the right variables/save name, you don’t need to *set it again.
You will most likely want to save before the player makes a handful of choices that will result in the player dying or getting caught and during which some variables are altered.
Step Five
Of course if you save, you might want to load too… it’s kinda the point. (You would load this when the player dies and has to start back at the checkpoint or whenever you want)
To load your save, do this:
*set save_num 1
*gosub_scene twiger_functions load
This will ‘instantly’ replace the values of all the variables listed with the values saved in the save variables save_1 and save_1b
Once again, you and use whatever save variable you want and if save_num is already set to the right name, you don’t need to change it:
*set save_num "playerdeath"
*gosub_scene twiger_functions load
*set save_num 5234
*gosub_scene twiger_functions load
Step whatever number we’re on
To rewrite your save, just do step four. You can use a save as many time as you want.
This is pretty open ended and the source is can very easily be altered so you can really do whatever you want with it.
How should I order my code?
probably like this:
(at the start of a scene in which a player might die)
[save the variables]
[label to goto when the player dies]
[load the variables]
[the story, choices, whatever]
[If the player dies anywhere: *goto label]
Thanks for checking this out. It took a few frustrating hours to makes.
Man, someone is going to use this and make a really successful game series with it and I’ll be poor.