I6: How to determine in code if a restore succeeds or fails?

My WIP has an initial menu (like The Blind House, and others) where the user can choose to restore a previous game. If the restore fails, then I don’t want to let the user out of this initial menu. However, to determine that, I need to know whether the restore fails or succeeds within I6/Glulx. Any ideas? Thanks.

I think you can safely assume that any code after the restore statement will only be executed if the restore failed.

The easiest way to do this is to find the code that prints the default success or failure messages and insert your custom code there. You can provide custom instructions for a failed restore, as well as do anything you like after a successful restore.


I have a different set of windows operating in the initial menu than I do in the main game. I’m not sure at this point whether or not a restore would even work without custom code; however, I do know that when a restore fails, it jumps out of the menu to the usual prompt. That’s highly inelegant, and looks broken.

I thought that there would be some globals set upon failure or success, but I can’t find them. I really don’t want to hack the libraries to find out whether it succeeded or not, but I guess that is a last-ditch option.

Well, you could set the turn count to 0 at the earliest opportunity, then set it back to 1 just before reading in the first command. This will mean that any successfully restored game must have a turn count of at least 1, whereas the turn count will be still be 0 if the pre-game restore fails.


In my projects, I usually have a number variable called game_started. I leave it at 0 while the player’s up in the menu area, and I have a ‘when play begins: now game_started is 1’ rule. So by definition, any restored game will have that flag set to 1.

If you put in this system, all you need to do is add a line after the from-menu restore attempt checking to see if game_started is still 0. If it is, you know the restore failed.

As it turns out, in I6/Glulx, you pretty much have to hack the library, or at least create a new verb to replace Restore (much cleaner). Thanks for steering me that direction. Here’s what I did:

  1. Created a new verb to substitute for Restore, but copied all of the RestoreSub in
  2. Modified the RestoreSub to set a global variable to tell if the restore was successful (oddly, RestoreSub doesn’t do this by itself), and also checked to see if we were still in the menu. If in the menu, don’t do the default restore.
    3.Checked for the variable in the menu, and if it was true, fall out of the loop and into the restored game

The turns trick is cleaner still, but I had a solution before I checked back here (you guys are fast).