Hello everyone. I'm using AC v 1.74.2
I have a "continue“ button in my main menu. I'm using the "continue from last save" node. It works great when I'm on a single computer. However, I noticed that it uses OptionsData to determine the last save from the ID.
public static bool ContinueGame ()
{
if (Options.optionsData != null && Options.optionsData.lastSaveID >= 0)
{
return LoadGame (Options.optionsData.lastSaveID);
}
return false;
}
This causes problems when trying to continue on another device with synced save files. The options data is saved to player prefs, and thus, not carried over to the new device. So on the new device, the lastSaveID might be different or not exist at all. So is there some setting or something I could do to safely retrieve the last save? Or a way to edit the script to do so?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can switch your Options file handled to OptionsFileHandler_SystemFile to have Options data be placed in files in the same way as save-games:
Otherwise, a custom script could read the save files themselves and work out which has the latest modified timestamp.
A function along these lines should return the ID of the latest save this way:
Oh great! So I could just add this to a script in my main menu and set Options.optionsData.lastSaveId to this?
Either that, or store it in a Global Variable that's used to load the save by ID directly.
Before that, though, check that the returned value is correct.
I tried that in the editor and it worked fine after some minor adjustments. However, it didn't work on Xbox because the files are different. I was thinking of using the updateTime stored on the SaveFile.
How could I write it to get each save's time from Kickstarter.saveSystem.foundSaveFiles?
I tried using that but that value is a very big negative number and it seems that if I just compare them using >, the oldest one is the bigger number.
If you're porting to Xbox, what is your SaveFileHandler? It's in that script that updateTime is set.
If both are negative, is that to say the oldest one has the largest absolute value, or the one closest to zero.
v1.74.2 is very old now, and it's possible there is an issue with the way timestamps were recorded, but the values should still be ordered and a comparison of updateTime should be OK To do.