Page 1 of 1

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

Posted: Wed Mar 15, 2023 12:02 pm
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

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

Posted: Wed Mar 15, 2023 12:04 pm
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.

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

Posted: Wed Mar 15, 2023 12:12 pm
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 188 times

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

Posted: Wed Mar 15, 2023 1:44 pm
by Ultroman
Is there anything else I can check for? Is there a sync-method I can call or something?

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

Posted: Wed Mar 15, 2023 1:54 pm
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.

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

Posted: Wed Mar 15, 2023 10:02 pm
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.

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

Posted: Wed Mar 15, 2023 10:10 pm
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.

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

Posted: Thu Mar 16, 2023 6:14 am
by Ultroman
Thank you very much! We'll update as soon as we can.