Non-persistent Dialogue System and saving

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
urrmurrmur
Posts: 58
Joined: Wed May 05, 2021 1:57 pm

Non-persistent Dialogue System and saving

Post by urrmurrmur »

Hi,

I'm currently considering my options for setting up a save system for my game, and would like some advice.

My game is set up with a separate database for each scene, plus a master database which is loaded in every scene. This works fine as long as no saving / loading is needed. Everything that needs to be transferred between scenes is in the master database, all the rest is just loaded along with the scene. Nothing in my game is persistent at the moment, nothing gets transferred between scenes.

Of course, if the user can save and reload the game at any time, the data in my scene-specific databases also needs to be saved somehow. I can think of a hundred ways to approach this, and I've done some reading around the documentation, but I'd like your opinion before making any decisions.

I had a smaller project that used DSFU before, where I set up my own basic save manager that uses

Code: Select all

string s = PersistentDataManager.GetSaveData();
PersistentDataManager.ApplySaveData(s);
Which worked fine, though that project only used a single database. I was considering something similar now, but with one save file per database. That way I can just apply the save data from the current scene, plus the master database, upon scene load. However, I have the impression that this is a nonstandard approach, and that there are no methods to get or apply save data on a per-database basis.

I could of course use the built-in save system, but I gather from the documentation that this doesn't play well with multiple databases:
<The initial database> should include everything that needs to be in a saved game
This implies that everything that's not in the initial (master) database doesn't get saved.

Of course, the nuclear option is to get rid of my multiple databases altogether and just merge everything. Either by making one big database file, or by loading all databases in every scene. In the latter case using GetSaveData may work - though I'm not sure. The save data only seems to contain variable names, not ids, so I don't know what would happen if the same variable name was used in multiple scenes.

Any ideas / opinions? What would you recommend?
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Non-persistent Dialogue System and saving

Post by Tony Li »

Hi,

Sorry if the documentation is unclear. It's fine to use the save system with multiple databases. Some tips:

1. Set a Base ID for each database (e.g., 10000, 20000, etc.) so they're more likely to keep their internal IDs unique from each other.

2. Use the Unique ID Tool at least once to make sure IDs across your databases are unique. Technically if you have a master database and a scene-specific database that's only loaded in the scene, you only need to ensure that each scene's scene-specific database's IDs are different from the master's. In this scenario, it's okay for one scene's database IDs to be the same as another scene's database IDs.

3. Use an Extra Databases component to load the scene-specific database at runtime. When an extra database is loaded at runtime like this, it's temporarily merged into the Dialogue Manager's masterDatabase. It's the masterDatabase that the save system saves, not the Initial Database assigned to the Dialogue Manager.

4. Set the Save System component's Frames To Wait Before Apply Data to 1 so that it waits 1 frame for the Extra Databases component to load the scene-specific database into the masterDatabase.
Post Reply