Howdy. Happy New Year. Been a while since my last post. Hope everyone is doing well.
If someone already solved this problem, I didn’t find the solution when I searched the forum topics, and it took me a few hours to figure this out; hopefully someone finds this helpful. Very happy to get feedback or improvements.
I was playing around with CS and found what I think is a coding solution to enable choice-by-choice “rewind” (or arbitrary frequency). I put this in my code for testing, but I think it could also be used as a general player facing feature or creatively.
Basically, this code allows for saving a checkpoint before every choice that does not get overwritten until after the next choice.
If you just put a *save_checkpoint rewind before every choice, by the time the player (or tester) sees the next choice, the checkpoint will be overwritten.
This is my alternative:
in startup.txt:
*comment "jrc" is "just restored checkpoint"
*create jrc_rewind false
*create jrc_rewindaux false
*create jrc_rewindreturn false
*create checkpoint_exclusions "jrc_rewind jrc_rewindaux jrc_rewindreturn"
in a subroutine file (mine is called “xsubr” for example):
*label rewind_highside
*comment This subroutine sets the location to which the rewind option will deliver the player. Must be paired with rewind_lowside on the low side of the intervening content (usually a *choice or *fake_choice block).
*set jrc_rewindaux false
*save_checkpoint rewindaux
*if (jrc_rewindaux)
*set jrc_rewind false
*save_checkpoint rewind
*if not(jrc_rewind)
*set jrc_rewindreturn true
*restore_checkpoint rewindreturn
*return
*label rewind_lowside
*comment This subroutine causes the preceding rewind checkpoint to be saved. Must be paired with rewind_highside on the high side of the intervening content (usually a *choice or *fake_choice block).
*set jrc_rewindreturn false
*save_checkpoint rewindreturn
*if not(jrc_rewindreturn)
*set jrc_rewindaux true
*restore_checkpoint rewindaux
*return
Then, at the beginning flow of the game (e.g. at the end of startup.txt, at the beginning of your first scene, or otherwise just before calling either subroutine) save all three checkpoints using:
*save_checkpoint rewind
*save_checkpoint rewindaux
*save_checkpoint rewindrestore
Saving the checkpoints before calling the subroutines makes them work the way that you’d expect, if they’re not saved before, you will get an error that says that there’s no checkpoint saved in rewindrestore (i think I know why this happens, but it’s not relevant here, as long as you save all three checkpoints before calling the subroutines, it will work).
And finally, in the main flow of the game, call the rewind_highside subroutine before a *choice or *fake_choice block; then call the rewind_lowside subroutine following the *fake_choice block or as part of the results of each choice in the choice block.
For example using *fake_choice:
*gosub_scene xsubr rewind_highside
Here's the situation.
Which choice will you make?
*fake_choice
#Choice 1
Text 1
#Choice N
Text N
*gosub_scene xsubr rewind_lowside
For example using *choice:
*gosub_scene xsubr rewind_highside
Here's the situation
Which choice will you make?
*choice
#Choice 1
*gosub_scene xsubr rewind_lowside
*goto result 1
#Choice N
*gosub_scene xsubr rewind_lowside
*goto result N
Then call the rewind checkpoint at any time (outside of the rewind subroutines) using *restore_checkpoint rewind
Let me know if you have thoughts or questions ![]()
Edits: I accidentally hit post then forgot to name the topic. Then I forgot to explain how to restore the checkpoint.
