Check for save file automatically


Is there a way to automatically check if in the same folder as the game file there is a save file for the game?

if so, how do i do the thing?

the goal is to be able to do the following:

no save game : starts a new game right away

game file found : “do you wish to continue your adventure?” Y/N

Y - load game

N - new game

If you’ve saved with a specific file name you could try to restore from that file and see whether the restore fails, but there are other reasons that could happen other than the file not being present.

Depending on what you’re trying to accomplish, you might want to have a look at Victor Gijsbers’s Permadeath extension. (Not sure if this is the latest working version.)

I’ve edited the OP so it’ll be clearer.

I don’t think there’s any way to check whether a save file exists unless you try to use it (actually restoring the game).

To do what you want I think you’d need to look for the existence of any .sav files in the games’ directory.

I may be wrong, but I see nothing in the documentation that leads me to believe that’s possible. In Inform, you apparently “declare” the files - no extension - and then use them as you will. I’m not even sure an Inform game could make use of a file whose name hadn’t been predicted by the author.

So, I’m guessing the answer is no, that’s not possible. But as usual, if someone does chime in with a solution, I’ll be all ears - it’ll be a cool solution.

Peter is correct: this isn’t possible.

In theory an interpreter can be built to auto-save state and always launch where the player left off. (Mobile interpreters do.) However it requires a lot of custom interpreter tooling.

That’s also possible in the game side, I see it happen in KerKer. Well, not quite the same. You have the option to merely “continue” your last game. But if that framework exists, it would be trivial to adapt it so that when the game launched it would automatically restore that game. You’d have to check whether the file exists, of course - KerKer manages it, so I know it’s possible.

None of this is easy, though. And you’d have to save the game at every turn to your “autosave” file, because you have to account for the player turning off the interpreter instead of going “quit”.

I don’t think anyone uses “quit” anymore today, do they? Doesn’t everyone just close the terp?

(this is all a bit less on-topic now. What has been originally asked isn’t possible; since a workaround is to have the game automatically load a previously created automated save file, I thought I’d follow Zarf’s lead)

I always type quit. i thought everyone did. o.o i don’t have to remove my hands from the keyboard to exit a game… i don’t wanna move over to my mouse unless i really have to.

Yes, what the OP is after is possible if the author retains control over the naming of the save file. Kerkerkruip does it by disabling the manual save interface and autosaving the game every turn. At startup, it checks for the save file, and if it finds it, asks whether the player wants to load it.

Aha, so there is a way to check whether a named save file exists? I’ll need to add that to my Autosave extension.

You have to extend I7’s interface to allow it to refer to the saved file in the same way as you can data files. The Kerkerkruip extension shows how to do it (I think matt w’s is too early to have this feature): … adeath.i7x

Sweet. And I gather this wouldn’t interfere with the usual savegame routine, would it?

I mean, if the player has three saved games of their own and deletes the autosave, the game will start afresh the next time it’s loaded, not having found the autosave and not looking for anything else - but that’s acceptable behaviour, innit?

Yes, but you would probably want to avoid the case where the player saves her game over the autosave–that likely indicates confusion on the player’s part and obviously would not have the desired result (i.e., the autosave will quickly overwrite the player’s save). I haven’t looked at the code in a long time, but that’s probably doable too. (It wasn’t an issue in Kerkerkruip, because the manual save system was totally disabled.)

If nothing else the terp would probably give a warning of “are you sure you want to overwrite the file autosave.glksave” or something.

Dunno if that’s much of an issue, a player doing that is asking to be confused.

That sounds great if your target audience is strictly players who already know how to play parser IF very well. Kind of not so good for everybody else, though. (Speaking of which, I’d probably move to a save slot system–also quite possible–rather than require the player to do any manual saving at all. But that wasn’t part of the original post.)

That’s probably ok - the OP wasn’t possible as envisioned, so looking for viable alternatives should be allright.

As for the rest, well, I dunno. Game-saving isn’t just a feature of IF, or even adventure games, and in any game it should be obvious that if you overwrite the autosave saved game you’re asking for trouble. I’m always partial to giving the player all the rope he wants to; I do sometimes hang myself, but mostly I manage to make a pretty nifty lassoo. (Maybe I stretched that metaphor too far?..)

Yeah it’s fine. IDGAF.

Hey while we’re all off topic, who wants to try out what I’m working on? PM me.
Very basic for now but just to get a feel of the atmosphere it’s got.

Glulx effort. looks tiny but most of the work is on the entrails.