Page 1 of 1

Integration with AC's saving system and new variables

Posted: Sat May 20, 2023 12:37 pm
by rairun
I created an AC save game, which keeps Dialogue System's data saved in one string variable. Then I created a new DS conversation (ID 28), and in an already existing conversation, I used the following condition: Conversation[28].Dialog[3].SimStatus == "WasDisplayed"

If I run the existing conversation when I start the game, there are no issues there. The condition is parsed properly. But if I load the AC save game, and then run the conversation, I get this console error: Dialogue System: Lua code 'return Conversation[28].Dialog[3].SimStatus == "WasDisplayed"' threw exception 'Lookup of field 'SimStatus' in the table element failed because the table element itself isn't in the table.'

I believe that if you're using DS's own saving system, this can be remedied by making sure Dialogue System's Persistent Data Settings > Initialize New Variables is ticked (I already had it ticked). But when you load an AC save, this initialisation doesn't occur.

Re: Integration with AC's saving system and new variables

Posted: Sat May 20, 2023 11:32 pm
by Tony Li
Hi,

Are you using the Remember Dialogue System component?

If so, the Initialize New Variables checkbox should take care of this when using Remember Dialogue System, even when using the AC integration.

Have you set up the Dialogue System save system (i.e., added SaveSystem, JsonDataSerializer, and PlayerPrefsSavedGameDataStorer)? It's not necessary, but it changes the way the Remember Dialogue System component works. Internally, if you're set up the save system, Remember Dialogue System calls SaveSystem.ApplySaveData(). If you haven't set up the save system, Remember Dialogue System calls PersistentDataManager.ApplySaveData().

If you're not using the Remember Dialogue System component, how are you getting the save data in the AC variable back into the Dialogue System on load?

Re: Integration with AC's saving system and new variables

Posted: Sat May 20, 2023 11:52 pm
by rairun
Hi Tony, thanks for the answer!

Yes, I'm using the Remember Dialogue system component, but I haven't set up the Dialogue System save system. These are the settings:

Image

Image

Saving and loading via AC usually does get all the Dialogue System data saved and restored without any issues. I'm really only getting errors when an AC save game is made before a given conversation is created in the database (so the AC global variable linked to DS doesn't have any data about that specific conversation). Only when the new conversation is created and the old save is loaded do I get errors when a condition refers to that conversation.

Re: Integration with AC's saving system and new variables

Posted: Sun May 21, 2023 3:45 pm
by Tony Li
Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?

Alternatively, put a breakpoint on the first line of the PersistentDataManager script's ExpandCompressedSimStatusData() method. Check if it gets past the first line:

Code: Select all

if (!(includeSimStatus && DialogueManager.Instance.includeSimStatus)) return;

Re: Integration with AC's saving system and new variables

Posted: Sun May 21, 2023 6:13 pm
by rairun
I haven't created a reproduction project yet because it'd bit a bit more finicky than usual (I'd have to include the AC save files + profiles, etc). But I did follow your advice and did this:

Image

which resulted in this:

Image

Those are all the conversations, correctly listed!

But I'm still getting errors like this after loading the old save, when a check makes a reference to conversation 28, as long as conversation 28 has not been run yet (if it is run after loading the save, then the check doesn't produce an error):

Code: Select all

Dialogue System: Lua code 'return Conversation[28].Dialog[3].SimStatus ~= "WasDisplayed"' threw exception 'Lookup of field 'SimStatus' in the table element failed because the table element itself isn't in the table.'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:228)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.Lua:IsTrue (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:171)
PixelCrushers.DialogueSystem.ConversationModel:EvaluateLinksAtPriority (PixelCrushers.DialogueSystem.ConditionPriority,PixelCrushers.DialogueSystem.DialogueEntry,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Response>,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Response>,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.DialogueEntry>,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:426)
PixelCrushers.DialogueSystem.ConversationModel:EvaluateLinks (PixelCrushers.DialogueSystem.DialogueEntry,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Response>,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Response>,System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.DialogueEntry>,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:406)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry,bool,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:300)
PixelCrushers.DialogueSystem.ConversationModel:.ctor (PixelCrushers.DialogueSystem.DialogueDatabase,string,UnityEngine.Transform,UnityEngine.Transform,bool,PixelCrushers.DialogueSystem.IsDialogueEntryValidDelegate,int,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:146)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation (string,UnityEngine.Transform,UnityEngine.Transform,int) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1008)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation (string,UnityEngine.Transform,UnityEngine.Transform) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1083)
PixelCrushers.DialogueSystem.DialogueManager:StartConversation (string,UnityEngine.Transform,UnityEngine.Transform) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueManager.cs:490)
AC.ActionDialogueSystemConversation:Run () (at Assets/AdventureCreator/Scripts/Actions/ActionDialogueSystemConversation.cs:105)
AC.ActionList/<RunAction>d__46:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:467)
UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:408)
AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:616)
AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:575)
AC.ActionList/<RunAction>d__46:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:539)
UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:408)
AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:616)
AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:575)
AC.ActionList/<RunAction>d__46:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:539)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
Interestingly, if I click "Play" and run an unrelated conversation (the DialogueSystemEnvironment AC variable is an empty string, but after we run any conversation it becomes populated), the conversation 28 entry looks like this:

Code: Select all

Conversation[28].SimX="1;u;2;u;3;u;4;u;5;u;0;u";
But after loading the old AC save, it looks like this:

Code: Select all

Conversation[28].SimX=""
That is, as the debug logs in the beginning of this post show, conversation 28 was processed on load! The issue seems to be that the entry doesn't actually become populated until the conversation is run, and so any checks against it return an error.

This I suppose leads me to another question: if rather than adding a new conversation, we added a new NODE to an existing conversation, and then we loaded an old AC save, the same error would likely occur, correct? Meaning, if we checked against the new node's status after loading the old save but before running the conversation (which seems to update the data), we'd likely run into the error too.

Re: Integration with AC's saving system and new variables

Posted: Sun May 21, 2023 9:44 pm
by Tony Li
Looks like I introduced a bug in a recent update that wasn't covered by unit tests. This patch should fix it:

DS_PersistentDataManagerPatch_2023-05-21.unitypackage

New dialogue entries in existing conversations were already handled properly. This patch just fixes the issue where new conversations' SimStatus info wasn't being added properly after loading a saved game that didn't have the new conversation's info.

Re: Integration with AC's saving system and new variables

Posted: Sun May 21, 2023 10:49 pm
by rairun
Appears to be working now! Thanks again for the help, I really appreciate it.

Re: Integration with AC's saving system and new variables

Posted: Mon May 22, 2023 8:24 am
by Tony Li
Glad to help! Thanks for letting me know about the bug.