save multidatabase

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

save multidatabase

Post by alfonso »

Hi tony!
it is possible to save a database in particular, im using multi database and i allways have 2 database loaded, and i switch one of them between chapters, i think the save system work over a big one database where all the databases are loaded right?

thanks
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: save multidatabase

Post by Tony Li »

Hi Alfonso,

The save system saves the Lua environment. When you load an extra database, it adds its data to the Lua environment. When you unload the database, it removes its data from the Lua environment.

Since the save system saves the Lua environment, it saves the runtime data of all loaded databases.

Many people who use multiple databases use a main database that's always loaded (and assigned to the Dialogue Manager's Initial Database field). This contains "global" information that you always want to include in saved games.

Then they load and unload other databases as they move between chapters, villages, planets, etc. These other databases contain data that's only used in that chapter or location and don't need to remember anything when leaving. If you need to remember something -- for example, a choice the player made on another planet -- put that data in the main database.

If you really need to save only one database, you could try this:

1. Save the entire Lua environment:

Code: Select all

string allData = PersistentDataManager.GetSaveData();
2. Remove all the other databases:

Code: Select all

DialogueManager.RemoveDatabase(someDatabase); // Repeat for all databases except the one to save.  
3. Get the Lua environment:

Code: Select all

string data = PersistentDataManager.GetSaveData();
4. Add the other databases back, and restore the data:

Code: Select all

DialogueManager.AddDatabase(someDatabase); // Repeat for all.
PersistentDataManager.ApplySaveData(allData);
The saved data for your one database will be in the data variable.

But, given the way that the Dialogue System works, you probably don't want to save it like this.
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: save multidatabase

Post by alfonso »

mmm then no matter in which database was the data but if the Lua enviaroment have it?

i mean, i have a _global one where is all the quests, variables, and more, but in each conversation (the others databases) I have a Count value to know how many times you speak to a npc and with this value say one thing o another.

so if i for example keep all the lua environment, its ok if i have some data of a database that is not loaded? that can produce an error or something?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: save multidatabase

Post by Tony Li »

Hi Alfonso,

It's okay to have the extra data. It shouldn't produce any errors.
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: save multidatabase

Post by alfonso »

great them i think is more easy to have a big luaEnvironment with all player progress.

thanks for all men
Post Reply