A little while back, I asked a seemingly unrelated question about checking if something was a number. That was resolved by figuring out how to do what I wanted to do without that check. So what did I want to do? I wanted to set up a system to allow me to skip ahead to the sections of the game that I wanted to playtest without replaying everything before.
This is a refined, more elegant version of the code I ended that other thread with. I’m pretty proud of it, and I wanted to share. The system works by actually playing the game according to the entered code, in silence, so there’s no need for any additional coding to account for convoluted story branches.
In startup.txt:
*create skipcode "111111111111"
*create skipdist 0
*create SN 1
*create XX 0
*create savecode ""
*create option "continue"
*create Nc 0
*create Nx 1
Enter your bookmark code:
*input_text skipcode
*set skipdist length(skipcode)
*finish
(The funny thing about the initial skipcode setting is that even though it works with just one digit or no digits at all to begin with–I mean, if it’s going to be referenced, it will have been changed for whatever you input–Quicktest will fail unless there are as many digits as chapters. I believe Quicktest is testing code that should not be called under the circumstances.)
You also need the following subroutine. I’ve been putting it in each chapter and accessing it via *gosub, but it occurs to me that you could put it just once somewhere and access it with *gosub_scene instead. This might solve the above issue of the initial skipcode setting and the Quicktest fail.
*Label Skip
*set XX skipcode#SN
*set SN +1
*set Nx 1
*label Loop
*if (XX = "${Nx}")
*set option "${option}"&"${XX}"
*return
*if (Nx < Nc)
*set Nx +1
*goto Loop
*set skipdist 0
*return
Within each chapter file, choices should look something like this:
*set option "01c"
*if not(SN > skipdist)
*set Nc 3
*gosub Skip
*if not(option = "01c")
*goto {option}
*choice
#Choice number one
*label 01c1
*set savecode "${savecode}"&"1"
*goto Choice1
#Choice number two
*label 01c2
*set savecode "${savecode}"&"2"
*goto Choice2
#Choice number three
*label 01c3
*set savecode "${savecode}"&"3"
*goto Choice3
(EDIT: I should clarify that “*set Nc 3” means “set Nc to the number of options in this choice”, which is not always 3.)
Each contiguous block of text needs to be prefaced with the following statement:
*if (SN > skipdist)
And in choicescript_stats.txt, include the following:
Bookmark code:
*line_break
${savecode}
From a designer’s standpoint, sooner or later you start to recognise some of the significant digits, and this allows you to skip ahead while tweaking past choices and therefore elements of the character sheet.
Things to watch out for:
- Make sure stat changes, story branching, and so on do not occur inside the “if (SN > skipdist)” indent block. Anything that happens in there must be related to text and text only.
- The one shortcoming appears to be that you can access hidden choices with this code: that is, if an early choice makes a later choice unavailable, this code could allow you to still sort of “have your cake and eat it too”: you could tell the code that, why yes, you did avail yourself of that choice that should not have been available to you, and it would go ahead and give it to you.