Page 1 of 2
Understanding how to Use Save System Slots
Posted: Wed Sep 01, 2021 2:20 am
by nathanj
Hi Tony,
been a while, hope you are well.
Setting up the save system for the first time and a massive thank you for doing this, it saves me
a lot of hassle
Is there an example or outline of how you would go about allowing users to create new instances of saved games and load those instances with this system? I'm just trying to get my head around the loading and saving of slots dynamically and how i invision things is often between 90 and 130 degrees from intended use, so before I start going down a path I was wondering if there was any documentation on this process before.
Thanks as always,
Nathan
Re: Understanding how to Use Save System Slots
Posted: Wed Sep 01, 2021 8:37 am
by Tony Li
Hi Nathan,
Slot numbers are really just unique numeric identifiers, kind of like arbitrary dictionary keys. They don't have to be sequential. You could save games in slots 1, 7, and -63 if you want.
The Save System for Opsive is primarily a back-end data/system asset. It ships with a very simple test script that always saves to a single slot number. It's up to you to provide a UI to allow the player to specify which slot(s) to save/load.
For an example, you can look at the Dialogue System's free Menu Framework addon available on the
Dialogue System Extras page. It's a front-end for the Save System and Dialogue System that allows the player to save and load games to different slots.
Re: Understanding how to Use Save System Slots
Posted: Wed Sep 01, 2021 7:15 pm
by nathanj
Perfect,
Thanks Tony
Re: Understanding how to Use Save System Slots
Posted: Wed Sep 01, 2021 9:33 pm
by Tony Li
Glad to help!
Re: Understanding how to Use Save System Slots
Posted: Fri Sep 03, 2021 2:33 am
by nathanj
Hi Tony,
Apologies is this is an obvious question, how to I retrieve all used slots from the Save System?
I'm trying to do a check on start to populate a ui panel with buttons for each saved instance and I can not figure out where this is stored.
Thank you,
Nathan
Re: Understanding how to Use Save System Slots
Posted: Fri Sep 03, 2021 8:04 am
by Tony Li
Hi Nathan,
You can look through the number of slots you allow and check
SaveSystem.HasSavedGameInSlot(#):
Code: Select all
for (int slot = 0; slot < MaxSlots; slot++)
{
if (SaveSystem.HasSavedGameInSlot(slot))
{
Debug.Log($"Slot {slot} has a saved game.");
}
}
Re: Understanding how to Use Save System Slots
Posted: Fri Sep 03, 2021 7:26 pm
by nathanj
That’s exactly what I was looking for. Thank you!
Nathan
Re: Understanding how to Use Save System Slots
Posted: Fri Sep 03, 2021 8:59 pm
by Tony Li
Happy to help!
Re: Understanding how to Use Save System Slots
Posted: Mon Sep 06, 2021 12:24 am
by nathanj
Hi Again, Tony
having a strange issue where data seems to be shared between users for the first few times that they enter. For example, I have 5 alocated slots for users to chose from. If player one logs in to slot 1 and saves and then player two logs into slot 2 they start where player one left. If they save and then player one logs in again they are where player 2 left. But then when player two logs in again they are where they left, not where player 1 left.
From that point on they are independant and their save systems work. But up to that point there is some overlap. Can you think of what might be causing this?
To log into a saved game I call
To load in if there is no saved game in the slot I call: SaveSystem.LoadScene("Maiwar2k_SP");
and to save I'm calling
My components in my loadscene look like this:
One thing I am not sure exactly about, but it seems to be working, is the UISSaver when I have the Save System and Dialogue System as persistent and the UIS in the scene. But, as I said, at the moment that seems to be fine. At the moment it's just getting the player's to have unique saving data from the start.
Any ideas what I could be doing wrong?
Thank you as always,
Nathan
Re: Understanding how to Use Save System Slots
Posted: Mon Sep 06, 2021 8:23 am
by Tony Li
Hi Nathan,
Untick 'Restore State On Start'. In general, this checkbox should almost never be ticked.
When a player logs out, call SaveSystem.ResetGameState() to clear old save data from memory.
If that doesn't help, what aspects of player one is player two inheriting? GameObject position? Inventory contents? Dialogue System variable values?