Code request for linking or loading a Checkpoint on a Chapter or a Save File

LA-Laker
For Example:

If I complete Chapter 1, and advance to Chapter 2: Chapter 2 will be unlocked as a continuation save point.

Is there an ON/OFF function, or a certain code to continue the game from where a player left off?

I'm not totally sure what you're asking, but here goes.

If a player puts down and picks up your game on the same browser/device, it will automatically pick up where they left off

If it's something like a "start over at various points if you die" thing, then you'll want to do the following

  1. set a flag on at the beginning of each chapter by doing
    @set ch1

  2. create a "you died" page that references those flags like so:

You died! Choose which point you want to start from:

{if ch1:[[Start from Chapter One]]
}
{if ch2:[[Start from Chapter Two]]
}

and so on. Each chapter will only be available to start from after the player as seen it.

However, keep in mind that this acts merely as more navigation links. The game is not aware that you have backed up. So, let's say that during chapter two, the player might get a curse put on them, or they might not. The easiest way to track something like this is just by using some sort of flag:
@set cursed
BUT, if the character then dies during chapter two (or later, and chooses to back up to chapter two), the game doesn't know to reset the cursed flag. The player might choose to avoid the curse, but then the game still behaves as though they are cursed later on.
The way I would do this is just to make a list of all the long-term effects that may or may not be applied during a chapter, and then make the first page of the chapter undo all of them. This way, the first page of chapter two has something like this at the top:
@unset cursed
@unset "otherflag"
@unset "anotherflag"

and any effects applied during that chapter will be restored. If the player never encountered the curse, this has no effect. The game attempts to unset the flag, but the flag is already unset, so it carries on as normal. The player is then free to either get cursed or not get cursed, and the game will behave as it should.

Now, if during chapter two your character talks with another character and has several opportunities to raise or lower how much that character likes them, it'll get more complicated, especially if the various opportunities to raise or lower that score are spread out, completely optional, etc. It's harder to restore a changeable variable. A flag is just an on/off switch. I have an idea about how to restore a variable to a previous state, but I won't bother working it out if you don't intend to use something like that.


Just a comment - you might figure a way to take advantage of the "seen" flag. So, if you have

[[chapter 2]]
Now it gets really dangerous...

And if you die, you might have code...

You have died. 
{if seen chapter2: [[chapter2]](pick up where you last died)}

If you want to restart, use that function at the top to clear everything.

And yes, flags for events in that chapter will be problematic.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums