Auto-loading the most recent save slot [SOLVED]

Started by shaun9991, Sun 07/08/2022 18:01:10

Previous topic - Next topic

shaun9991

Hey!

I have an "on key press" autoload function set up in my game. If the player presses F5, the game autosaves to slot 98. If the player presses F7, it loads up the autosave slot (98).

Code: ags
  if(keycode == eKeyF7){
   RestoreGameSlot(98);
   UnPauseGame();
}


How can I change this so that pressing the F7 key will actually load up the most recent save game in general? And how would I put a check in place in case no save games exist? Any help is much appreciated, I've been fiddling around with various possibilities but haven't managed to get it working.

ps. I use the standard AGS Load/Save system detailed here: https://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs

Many thanks!
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Crimson Wizard

#1
When you fill the list box using ListBox.FillSaveGameList, it sorts the saves by date (most recent first). You may create a hidden list box, fill it, and choose the first item in ListBox.SaveGameSlots[] array (SaveGameSlots[0]). If ListBox.ItemCount is zero, that would mean that there are no saves.

shaun9991

Thanks CW! :)

I'll try this out this evening.
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

shaun9991

Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

SMF spam blocked by CleanTalk