How do I save the dialog's variables using EasySave3?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
AHAKuo
Posts: 8
Joined: Sat Dec 05, 2020 12:41 pm

How do I save the dialog's variables using EasySave3?

Post by AHAKuo »

I'm using Dialog System to integrate simple conversations and using variables to decide what NPCs say.

However, I want to save those variables (booleans and strings, etc...) of the conversations using EasySave3. I've tried so far to do so using this set up:

Image


And I also tried writing this code:

Code: Select all

    /////This is the script which calls saving after dialog and loads at start of scene

    private void Start()
    {
        LoadDialog();
    }

    public void SaveDialog() //We call this method at the end of a dialog to save everything to the dialog base.
    {
        ES3.Save("DialogData", PersistentDataManager.GetSaveData(), "DialogData.neon");
    }

    public void LoadDialog() //We call this method at start, and at any other point we need.
    {
        if(ES3.KeyExists("DialogData", "DialogData.neon"))
        {
            PersistentDataManager.ApplySaveData(ES3.Load<string>("DialogData", "DialogData.neon"));
        }
    }

With those two methods above, the NPC's conversations always start from the beginning, i.e, all variables are in their default state as if they were not saved. I just want the variables of the dialog database to be saved, I don't care much about the quest, locations, etc...

But I do want the basic stuff to be saved. Thank you :)
AHAKuo
Posts: 8
Joined: Sat Dec 05, 2020 12:41 pm

Re: How do I save the dialog's variables using EasySave3?

Post by AHAKuo »

I fixed it!

I just modified my code to make it like this, hope it helps anyone!

Code: Select all

    /////This is the script which calls saving after dialog and loads at start of scene
    string DialogStore;

    private void Start()
    {
        if (ES3.KeyExists("DialogData", "DialogData.neon"))
        {
            DialogStore = ES3.Load<string>("DialogData", "DialogData.neon");
            LoadDialog();
        }
    }

    public void SaveDialog() //We call this method at the end of a dialog to save everything to the dialog base.
    {
        DialogStore = PersistentDataManager.GetSaveData();
        ES3.Save("DialogData", DialogStore, "DialogData.neon");
    }

    public void LoadDialog() //We call this method at start, and at any other point we need.
    {
        PersistentDataManager.ApplySaveData(DialogStore);
    }
All I have to do to save is call SaveDialog() from wherever, and then use LoadDialog at start.
Last edited by AHAKuo on Sat Dec 05, 2020 1:14 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How do I save the dialog's variables using EasySave3?

Post by Tony Li »

Thanks for sharing!
dogEleven
Posts: 2
Joined: Sat Mar 13, 2021 2:50 am

Re: How do I save the dialog's variables using EasySave3?

Post by dogEleven »

Thank you for sharing!❤️
Post Reply