Hi Chris! I've just updated AC from 1.81.7 to 1.82.1, and I got these console errors:
Assets_EverAfter\Scripts\SaveSetup.cs(19,44): error CS1061: 'OptionsData' does not contain a definition for 'lastSaveID' and no accessible extension method 'lastSaveID' accepting a first argument of type 'OptionsData' could be found (are you missing a using directive or an assembly reference?)
Assets_EverAfter\Scripts\SaveSetup.cs(23,43): error CS1061: 'OptionsData' does not contain a definition for 'GetPreviousSaveIDs' and no accessible extension method 'GetPreviousSaveIDs' accepting a first argument of type 'OptionsData' could be found (are you missing a using directive or an assembly reference?)
Assets_EverAfter\Scripts\SaveSetup.cs(38,44): error CS1061: 'OptionsData' does not contain a definition for 'lastSaveID' and no accessible extension method 'lastSaveID' accepting a first argument of type 'OptionsData' could be found (are you missing a using directive or an assembly reference?)
This is the script I had been using, which deletes all saves that are more recent than the one the player has chosen (i.e. loading a previous save permanently takes the player to that point in time, and they can't change their mind):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;
public class SaveSetup : MonoBehaviour
{
void LoadRewindSave()
{
AC.SaveSystem.LoadGame(AC.GlobalVariables.GetIntegerValue(15));
}
void RewindToSave()
{
int saveToRewindTo = AC.GlobalVariables.GetIntegerValue(15); // The rewind save variable
int lastSave = Options.optionsData.lastSaveID;
bool foundsave = false;
List<int> ListOfSaves = new List<int>();
ListOfSaves = Options.optionsData.GetPreviousSaveIDs();
for (int i = 0; i < ListOfSaves.Count; i++)
{
if ( ListOfSaves[i] == saveToRewindTo)
{
foundsave = true;
}
}
while (lastSave != saveToRewindTo && foundsave == true)
{
AC.SaveSystem.DeleteSave(lastSave);
lastSave = Options.optionsData.lastSaveID;
}
}
void RewindToBeginning()
{
List<SaveFile> ListOfSaves = new List<SaveFile>();
ListOfSaves = KickStarter.saveSystem.foundSaveFiles;
for (int i = 0; i < ListOfSaves.Count; i++)
{
AC.SaveSystem.DeleteSave(ListOfSaves[i].saveID);
}
ResetDialogueDatabase();
}
void ResetDialogueDatabase()
{
PixelCrushers.DialogueSystem.PersistentDataManager.Reset(PixelCrushers.DialogueSystem.DatabaseResetOptions.KeepAllLoaded);
}
}
Why can we no longer access lastSaveID and GetPreviousSaveIDs?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
They were removed - storing such data in Options (separate from the save files themselves) wasn't good practice, and tweaks were made to the SaveFile class to replace them.
The SaveFile class's GetUpdatedTime function can be read to get that save's timestamp.
If I'm following your intent correctly, you can record the timestamp of the save to load, and then remove saves that were made after it.
Something like:
Thanks you! I'm going to do some more robust testing later, but it seems to be working.
I have just noticed though that the Save-game Manager displays a "No save files found" message even when there are save files in the profile. A in-game save menu does display the saves correctly, but the manager doesn't find them.
I use this script, if it makes a difference:
And these are the console errors I get:
Open SaveFileManager and replace line 136 with:
Does that resolve it?
If not, are the Profiles being correctly loaded? If you're applying a custom file handler for Options, you'll need to make sure this is also set while in Edit mode.
It does, thank you!
Many, many AC versions ago, the profiles would only be loaded correctly on the manager while the game was playing - which was a little annoying. After an AC update (I can't remember which), this changed. To apply the custom file handler, it was only necessary to run a scene with the code above once, and the setting would stick while in editor mode as well. This is how it works now with the fix you've just provided - more than good enough for me!