Checking whether a specific savegame exists (SOLVED)

Started by Fitz, Mon 13/04/2015 11:17:39

Previous topic - Next topic

Fitz

I'm trying to make a simplified savegame system, based on autosaves/checkpoints. The game saves automatically when a certain point in the game has been reached -- and there's a checkpoint menu where the player can go back to any previous checkpoint (but not a checkpoint they haven't reached yet). The checkpoints would be auto-saved via SaveGameSlot command and loaded by the player clicking their respective buttons in the menu (which would run the "RestoreGameSlot" command). The question is:

- how do I get the game to detect whether a given savegame exists, most conveniently by the number I gave it in the code (say, 21 for the 1st checkpoint in Room 2)
- which property should I assign to the respective button if a savegame is absent: clickable = false or enabled = false?
- should I have those properties checked upon loading the checkpoint menu or somewhere else?

Also, another problem with savegames is that the game can't be saved inside cutscenes, only when the character is walking freely. If I put a savegame inside a cutscene, at the end of which a dialog is started or my custom fade-in gui runs, after the savegame is loaded it looks like none of these have been executed (there's no dialog started/the screen stays black). Is there an elegant workaround for that? Because the only way I managed to make it work is have a timer set to 20 cycles and disable all mouse modes, so that the player can't do anything in that time, save the game then, and enable the mouse modes again when the timer's expired.

monkey0506

Does File.Exists support $SAVEGAMEDIR$? By default the save games are named "agssave.XXX" (IIRC), so you should be able to pretty easily do:

Code: ags
if (File.Exists(String.Format("$SAVEGAMEDIR$/agssave.%03d", slot)))
{
  // ...
}

Crimson Wizard

#2
Usually people use GetSaveSlotDescription(int slot). If it returns null, the save slot does not exist yet.

Using File.Exists will hardcode the savegame format name. I can't say its a big issue, but it looks like intertwining game script with the engine innards.

Fitz

Some forum searching revealed that Peder worked on the exact same thing back in 2006. I took his code -- and it worked like a charm. The savegame system is up and running! Thanks!

Now, any suggestions on those mid-cutscene savegames? I mean, I've got something that works, but it's clunky and I want something more elegant.

SMF spam blocked by CleanTalk