Restart Game (Keeping Achievements)

Hi guys, I'm trying to code a 'restart game' feature that keeps certain aspects of your game.

I'm making a game where the player is intended to die (lots) and I'd love to keep a log of how many times they've died/what ways they've died, if it's possible. So they could look at a list of like, "died by rats," "died by sword," etc. instead of having to restart the game completely every time they die. It's just frustrating and game breaking when I know they're gunna die a LOT.

I can find a bunch of forum posts saying "you could just code that" but I'm not great with code! Anyone have any examples of how to do this? Or even how to throw them back to the first room with everything reset?


I'd recommend doing a Gamebook. The problem with doing that with normal text adventures is that you have all these objects to keep track of while with a Gamebook you have only a few objects to take care of.

I'd simply make booleans that keep track of the advancements the player made. Then, I'd move the player back to the first room with MoveObject (player, room) and then check to make sure if there are any other attributes or booleans that need to be reset.

Good luck with your game!

Unfortunately because I have all these objects to keep track of in the game, I can't have it be a game book... It's sort of a classic 'King's Quest' adventure game. Thanks for the tip, though!

This isn't such an easy thing to do.
There are two ways I can think of to achieve it:

  1. Create a 'template' world containing all your objects/locations, but instead of starting the game normally you clone the whole thing and send the player into a clone. When the player dies, you move them to a new clone and either destroy or archive the old one. (this basically means that you won't be able to refer to objects by name, but that's not such a big deal)

  2. When restarting, backup the achievements into a LocalStorage. This is probably the cleaner method, but for some reason LocalStorage is broken on the desktop version of the Quest player, so I'm not sure how well this would work. (also not sure how restarting works on desktop)

Is this really what you want Apo? In a game where death is frequent, players usually create checkpoints by saving the state of the game as they go along. Forcing them back to the start after death may not go down well.

Perhaps it would be better to give the player a checkpoint facility and return to the last checkpoint after death? A repeated use of UNDO feels like a possible way to return to the checkpoint but I don't know how to do that 'silently' to avoid the player seeing all of the intermediate steps. Any thoughts mrangel?

Hmmm. Thank you. A checkpoint system might work. The game is sort of based around these lists of stupid ways women in literature have died or old timey ladies have been committed to asylum.

So really what I need is a frequent way to run some sort of 'you died, here's an achievement for how you died, go back to X place with no items and all the variables back to original position.' I just thought it would be fun if they could keep track of how many times they died. They don't have to be thrown back to the very start of the game, necessarily, but the world is only about ten rooms, and once you figure out how to get through it without dying only takes like fifteen minutes to run...

I'm open to other suggestions if you think there's a better design answer in here somewhere!

I made a stupid and janky solution that I think works. I made a 'GAME OVER' room that just moves all the objects back where I had them, resets values, and offers players a chance to 'continue.' Achievements are a simple print list. It does mean that you can't ever use 'first enter' or count the number of times someone has done something on one run-through rather than the full game, but otherwise it works fine.

Thanks everyone!

A repeated use of UNDO feels like a possible way to return to the checkpoint but I don't know how to do that 'silently' to avoid the player seeing all of the intermediate steps.

That seems like it would be a neat way to do it. Though I'm not sure how transactions work; I think undo might not work over an actual game save.
Does 'undo' generate output? I can't remember, it's a long time since I played with it. But IIRC calling undo in a script resets everything except the script's local variables, so you could copy the achievements into a local variable to make them survive the undo.

Decided to create a demo game to try out the ideas discussed. It seems to work fine, even showing the undo steps.

I have now put the checkpoint facility into a full game.
It is the only one I'm involved in that has sudden deaths. Indeed, by default, the player is protected so to test out the checkpoint facility type PROTECT to reverse the protection flag. After that, a death can be found SOUTH, WEST, WEST, SOUTH and SOUTH (flying killer chickens!). Set a checkpoint at any time before the final SOUTH by using CHECK. Without a checkpoint, the game finishes with a little terminal music from Eric Matyas...thanks Eric!

Log in to post a reply.