Page 1 of 1

Saving only quests and quest variables

Posted: Wed Aug 23, 2023 1:23 pm
by LovreG
Hi everyone!
So I've been playing around the dialogue system the whole day today and I finally decided okay, let's check out the save system. As I previously already had saving system implemented in my game I didn't really need much of it. What I do need is to save quests and it's variables. Now, I tried researching this topic and found this forum post: https://pixelcrushers.com/phpbb/viewtop ... ave#p40173
Sadly, it didn't work for me. I tried implementing the whole saving system too, and after I do it quests do kind of save, but I can't open the quest log nor interact with npcs (plus the game is like 10 times slower). I would love to save only the quests though if that is possible. So if anyone has an idea of what to do, please do leave a comment!Thank you in advance! :D

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 2:36 pm
by Tony Li
Hi,

What part of

Code: Select all

string s = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
and

Code: Select all

PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(s);
didn't work for you? After applying save data, you may also want to call DialogueManager.SendUpdateTracker() to tell the quest tracker HUD to update its display with the restored data.

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 2:46 pm
by LovreG
After using those lines of code and saving it in the string variable s, after I try to retrieve the data next time I load up the game (I do it at the start method in the script, not with a public method with a button) nothing happens. I'm not sure what I'm doing wrong.

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 3:01 pm
by Tony Li
Try waiting until the Dialogue System is initialized. There are a few ways to do this, such as hooking into the DialogueManager.instance.initializationComplete C# event in an Awake() method, or waiting for DialogueManager.instance.isInitialized to be true. But the easiest is to wait until the end of the start frame:

Code: Select all

IEnumerator Start()
{
    yield return new WaitForEndOfFrame();
    PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(s); // Assumes 's' contains save data
}

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 4:26 pm
by LovreG
I did that. I set the string s to public to see what is going on, it saves it but when i restart play mode it does not load it. It's values remain empty. I even tried making a public LoadQuest method to try to load it from the button, it doesn't do anything. I followed your tutorial on youtube so I know the quest is set up properly. I'm sorry for taking so much of your time, I feel like an idiot haha.

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 4:43 pm
by Tony Li
Hi,

After you run this code:

Code: Select all

string s = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
Are you saving the value of s anywhere in your own saving system?

Make sure to retrieve the value of s from your own saving system before passing it to:

Code: Select all

PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(s);
Otherwise you'll just be passing an empty string, which will do nothing.

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 4:45 pm
by LovreG
I think I figured it out, I was at fault all along, being such an newbie I had an issue with my SaveSystem script. Thank you so much for your time!

Re: Saving only quests and quest variables

Posted: Wed Aug 23, 2023 4:46 pm
by Tony Li
Glad you got it figured out!