Save dialogue settings when closing application

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save dialogue settings when closing application

Post by Tony Li »

What are the settings on the Dialogue System Saver component?

Since you're using Auto Save Load with Load On Start ticked, you may need to delay the Dialogue System Trigger for one or more frames. Here's a test:

1. Change the Dialogue System Trigger to OnUse.

2. Add a TimedEvent component to the same GameObject. Set the dropdown to Frames. Set the value to 2. Configure the OnTimeReached() event to call the Dialogue System Trigger's DialogueSystemTrigger.OnUse method.
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: Save dialogue settings when closing application

Post by soniclinkerman »

Here are my settings
Settings.png
Settings.png (49.69 KiB) Viewed 545 times
2. Add a TimedEvent component to the same GameObject. Set the dropdown to Frames. Set the value to 2. Configure the OnTimeReached() event to call the Dialogue System Trigger's DialogueSystemTrigger.OnUse method.
I just replaced my "Start" conversation and made it use "OnUse" as you mentioned. So far, this seems to work except for the last level dialogue at the start of the game. Should I increase the amount of frames it takes?
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save dialogue settings when closing application

Post by Tony Li »

Hi,

Yes, that's correct. Since both Auto Save Load and the Dialogue System Trigger do their thing in Start, the trigger was going first. You can keep it set up the way it is now, or you can go into Script Execution Order and set Auto Save Load to run first.
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: Save dialogue settings when closing application

Post by soniclinkerman »

Gotcha. Ok I just went through the whole game and it looks like it works as intended!

You mentioned how to restart dialogue earlier using onclick, but I was curious if there was a way where it would restart on runtime WITHOUT having to load to the next scene right away?

I pretty much just want it to reset on the "Menu" scene without having to reload
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save dialogue settings when closing application

Post by Tony Li »

Hi,

To reset the data without loading a scene, call PixelCrushers.SaveSystem.ResetGameState().
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: Save dialogue settings when closing application

Post by soniclinkerman »

I just placed this in my script as shown

Code: Select all

if (Input.GetKeyDown(KeyCode.R) && canResetData)
        {
            PixelCrushers.SaveSystem.ResetGameState();
            Debug.Log("RESET");
        }
The console.log runs, but the game hasn't reset. Am I doing this wrong?

I put this on the top of my script

Code: Select all

using PixelCrushers.DialogueSystem;
It shows re squiggles, but I assume that's just because Visual Studio doesn't recognize this
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save dialogue settings when closing application

Post by Tony Li »

By "reset," I assume you want to clear all save data from memory and reset all Dialogue System variables to their initial values, correct? If so, that should do it. Make sure the scene has a Dialogue System Saver component at the time that you run SaveSystem.ResetGameState().
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: Save dialogue settings when closing application

Post by soniclinkerman »

Ok so my "Save System" GameObject has the script "Dialogue System Saver".

So what supposed to happens is: when I press the Z button, the game should just reset it's dialogue variables

Code: Select all

if (Input.GetKeyDown(KeyCode.Z))
                {
                    audioSource.PlayOneShot(selected);
                    PixelCrushers.SaveSystem.ResetGameState();
                    Debug.Log("RESET");
                }
But for some reason, this isn't actually producing those results. It always prints out "reset", but when I push the button that's meant to start the game, the retrieved data doesn't set the variables that are meant to go back to normal. They're still values from the "saved" version
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save dialogue settings when closing application

Post by Tony Li »

Thanks for the explanation. The problem is that you're resetting the variable values in memory, but then you're loading the old saved variable values from the saved game back into memory. If you use SaveSystem.ResetGameState(), don't undo that by reloading your saved game.

If you want to reset the game state and clear out the saved game, also call SaveSystem.DeleteSavedGameInSlot():

Code: Select all

PixelCrushers.SaveSystem.ResetGameState();
PixelCrushers.SaveSystem.DeleteSavedGameInSlot(1);
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: Save dialogue settings when closing application

Post by soniclinkerman »

That was it! Now it works as intended!

I can't think you enough for your help and guiding me through this. I really appreciate it. I'm about to leave a 5 start review right now for this product and amazing service !
Post Reply