PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Ultroman »

I'm using PersistentDataManager.ApplySaveData(dialogueSystemData-string) to load my data, and it all works fine, except if I add new Quests and then load a save from before the quests were added. I can't add a Watch for the new quest, and the quest doesn't work despite my calling QuestLog.SetQuestState() to make it Grantable.

Not sure exactly where the problem is. Is there a way to sync/add newly added things, or keep the extra data, when calling PersistentDataManager.ApplySaveData()?

We're on version 2.2.9
Last edited by Ultroman on Wed Mar 15, 2023 12:05 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Tony Li »

Hi,

Inspect the Dialogue Manager GameObject, and tick Persistent Data Settings > Initialize New Variables. Despite the name, it also initializes new quests that were added since the saved game file was made.
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Ultroman »

Dude, 2 minutes! You are ON IT! <3

Sadly, that option is already ticked.
DS Settings.png
DS Settings.png (47.16 KiB) Viewed 189 times
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Ultroman »

Is there anything else I can check for? Is there a sync-method I can call or something?
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Tony Li »

We'll need to get more info.

What version of the Dialogue System are you using?

Are there any errors or warnings in the Console window when you call PersistentDataManager.ApplySaveData()?

As a temporary test, edit PersistentDataManager.cs. Locate the "Lua.Run" line in the InitializeNewQuestEntriesFromDatabase() method, which is on line 1437 in version 2.2.34. Change it from this:

Code: Select all

Lua.Run(luaCode);
to this:

Code: Select all

Lua.Run(luaCode, true);
Then reproduce the issue. You should see a line in the Console that starts similarly to:

Dialogue System: Lua(Item["Quest Name"] = {..

This will give you an idea of which new quests it's initializing because they weren't in the original save data.
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Ultroman »

We're using DS version 2.2.9 and Unity 2021.3.16f1.

After an hour of trying to debug PersistentDataManager with no errors being shown, it suddenly started working, and I could confirm that it already had the new quests and their entries in its database, so it didn't need to add anything (it does seem a bit "scary" with the conditions for diff-checks being that the number of entries must be higher; what if one was removed and/or another added?).

So, it works. BUT, I still can't add a Watch for the new quests after calling PersistentDataManager.ApplySaveData() with the old data. I can add a Watch for them before I load, and then refresh it after loading, and that works fine.
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Tony Li »

I'll look into the Watches issue.

If you can back up your project, make sure your backup is good, and then update to the current DS version, I would recommend that. Make sure to read the release notes, too.
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

Re: PersistentDataManager.ApplySaveData() removes newly added Quests from new database

Post by Ultroman »

Thank you very much! We'll update as soon as we can.
Post Reply