Reject restore based on timestamp

I want to be able to reject a restore if it’s within a certain amount of time. I can easily save a timestamp in a variable when saving, but then when restoring how can I go back to the original state after checking the timestamp of the restored state?

The easiest way to do this is to save the undo state right before restoring, then if you’re rejecting the saved game file, jump back to that undo state. (Undo states are explicitly not affected by saving and restoring the game, to ensure that you can undo a restore. Which is exactly what you want to do!)

2 questions:
Do I need a new undo state or can I just use the existing one?
How do I cause a rule to fire immediately after a restore (what stage of the turn sequence rules are we at)?

I found the answer to question 2 in this post.

  1. Doesn’t matter, really. Making a new one or not isn’t a big difference.

  2. The rules that run immediately after successfully restoring are actually the rules for saving the game, because that’s the point in time you’ve jumped back to. The standard library doesn’t offer any convenient hooks into this process, but you can either hijack the responses system, or use a bit of I6 to insert your own rules there.

But how do I make the undo silent? There’s no way to set a flag because it’s erased by doing the undo.

There’s a way to work around that, but probably easier to make your own undo save, so that you can control exactly what’s output around it.

I got it all working, thanks @Draconis for all your help.

1 Like