How To Save

Announcements, support questions, and discussion for Quest Machine.
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

How To Save

Post by rnally01 »

Hi, I'm a new Quest Machine user and I'm trying to get saving going. I put the JSON Data Serializer and an ESSDataStorer on my Quest Machine configuration component which is on my player, but I'm not seeing it save anything in my persistent data folder. Before the ESSDataStorer I had the DiskBasedDataStorer component on and I did see it saved some .dat files (although they never seemed to load? or save anything).

Do you know what I am doing wrong? Do I have to have the JSON Data Serializer and ESSDataStorer on an object at the top of the hierarchy in each scene? Is the fact that it's on my player causing a problem?

Am I looking in the wrong place for the save file? Is it somewhere other than the persistent data folder?

Do I need to add an active saver to my quest giver or tell it to save on a trigger event? My understanding from reading the documentation was that the Quest Giver component itself would save the quest, but I don't see it saving anything in the persistent data folder and when I close and restart the game my quests are gone. This is true whether or not I complete the quest.

Do I need to load the data myself? Could that be why it looks like things aren't saving? If the Quest Giver component is saving data will it also load data or do I need to do that?

Thanks for the help,
Rob
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

Re: How To Save

Post by rnally01 »

Here are some screenshots of what I have setup on my end.
quest machine save 1.JPG
quest machine save 1.JPG (378.05 KiB) Viewed 884 times
quest machine save 2.JPG
quest machine save 2.JPG (582.26 KiB) Viewed 884 times
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To Save

Post by Tony Li »

Hi Rob,

Let's eliminate possibilities and then add Easy Save back into the mix.

Please remove the ES Saver Game Data Storer component, and add a PlayerPrefs Saved Game Data Storer component.

Then try saving a game and loading it.

If this works, we'll need to look at the Easy Save configuration.

If it doesn't work, we'll need to look at the save system configuration, or the way you're saving and loading. How are you saving and loading?

Also, do the Demo scene's Save and Load buttons work correctly in your project? I don't recall if it's configured to save the quest givers, but it does save the player's Quest Journal.
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

Re: How To Save

Post by rnally01 »

So I tried out the Demo scene, which I should have tried earlier (sorry), and that seemed to at least answer some questions. From playing the Demo scene, it does save. I just had to hit the Save button in the Menu and hit the Load button in the Menu to get it to Save and Load. When I read that Quest Givers or the system would Save on it's own I assumed I didn't really need to explicitly call the Save and Load functions, but it seems like that is the way to go from playing the Demo scene so I'll try that and see how it goes. I wasn't really explicitly calling any save or load (definitely not load) functions in my scene. I tried putting a few components on things, but didn't really get anywhere. I'll try calling some save and load functions explicitly in code somewhere and see how it goes.
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To Save

Post by Tony Li »

Hi,

If you want to automatically save and load, you can add an Auto Save Load component to the same GameObject that has your Save System component.
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

Re: How To Save

Post by rnally01 »

Do you know what I am supposed to pass in for the savedGameData parameter when calling StoreSavedGameData?
quest machine saved game data.JPG
quest machine saved game data.JPG (34.77 KiB) Viewed 878 times
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To Save

Post by Tony Li »

Hi,

What are you trying to accomplish? Normally the SaveSystem component calls StoreSavedGameData() for you. You shouldn't have to call any methods on ESSavedGameDataStorer yourself.
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

Re: How To Save

Post by rnally01 »

When I looked at the demo scene the Save and Load buttons were calling Save and Load functions in one of the scripts and that was how it seemed like the demo saved things so I thought I would need to call some save methods myself in order to save things. Since I have Easy Save I thought I would try to call the Save and Load functions that are in that class.

Should I be calling save and load functions from another script or class? In my game the player has an ability to save whenever they want so I thought I might call the save function when they press the save button for everything else.
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To Save

Post by Tony Li »

Using the save system is much simpler than all that. You only need to call methods in the SaveSystem class. Or, if you use a Save System Methods component (explained below), you don't even need to do that.

To set up the save system, add these components to a GameObject: Save System, Json Data Serializer, ES Saved Game Data Storer. The easiest way to do this is to download and import the Save System Prefabs, and drop the Save System prefab into your scene. The advantage of the Save System Prefabs package is that the Save System prefab is already preconfigured with components and a scene transition manager. After adding the prefab, you'll want to take two extra steps:

1. Replace the PlayerPrefs Saved Game Data Storer with an ES Saved Game Data Storer.

2. Add the LoadingScreen scene (included in the package) to your build settings. You can customize this scene.


To save a game from a C# script, call SaveSystem.SaveToSlot(#).

To save a game without any scripting, use a UI Button. Add a Save System Methods component to the Button's GameObject, and configure the Button's OnClick() event to call SaveSystemMethods.SaveToSlot.


To load a game from C#, call SaveSystem.LoadFromSlot(#). To load it from a UI Button, call SaveSystemMethods.LoadFromSLot.


Save_System_Manual.pdf contains a recap of this and additional info if you want to dig further into the save system.
rnally01
Posts: 14
Joined: Tue Mar 01, 2022 11:22 am

Re: How To Save

Post by rnally01 »

Thank you! I was able to get saving going, at least for now, using the DiskBasedStorer, AutoSaveLoad, SaveSystem.SaveToSlot and SaveSystem.LoadFromSlot.
Post Reply