Problems with save system.

Announcements, support questions, and discussion for Quest Machine.
Post Reply
DiegoGary25
Posts: 9
Joined: Wed Mar 05, 2025 11:42 am

Problems with save system.

Post by DiegoGary25 »

Hey Tony, sorry to bother again. I am trying to use the save system, yet I get this errors on start:
CloneList<QuestContent>: Element 0 is null in a list in 1 Open and Close Inventory (PixelCrushers.QuestMachine.Wrappers.Quest).
and
CloneList<QuestContent>: Element 1 is null in a list in 1 Open and Close Inventory (PixelCrushers.QuestMachine.Wrappers.Quest).

Then when saving:
Dialogue System: GetSaveData() failed to get item data: Object reference not set to an instance of an object
NullReferenceException: Object reference not set to an instance of an object
PixelCrushers.DialogueSystem.PersistentDataManager.AppendConversationData (System.Text.StringBuilder sb) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:733)


My scene looks like this:
1. My player with the player journal. (1) and with the dialogue system saver with the same ID.
2. the save system with the default values.

Any Idea why? thank you so much.
I am assigning quests through the GiveQuestToQuesterQuestAction.
Attachments
1.png
1.png (58.29 KiB) Viewed 13978 times
DiegoGary25
Posts: 9
Joined: Wed Mar 05, 2025 11:42 am

Re: Problems with save system.

Post by DiegoGary25 »

As aditional info my quest do have a different ID. thanks again!
User avatar
Tony Li
Posts: 23272
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems with save system.

Post by Tony Li »

Hi,

For the CloneList error, inspect the quest. From the gear menu, select Debug > Delete Unused Subassets.

For the save error, make sure your scene has a Dialogue Manager.
DiegoGary25
Posts: 9
Joined: Wed Mar 05, 2025 11:42 am

Re: Problems with save system.

Post by DiegoGary25 »

Hey again Tony, thanks for the reply! It did help, as I didn't get those errors. yet I got this one:
Quest Machine: Player Can't find quest guide1. Is it registered with Quest Machine?
UnityEngine.Debug:LogError (object,UnityEngine.Object)
PixelCrushers.QuestMachine.QuestListContainer:ApplyData (string) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:480)
PixelCrushers.QuestMachine.QuestJournal:ApplyData (string) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestJournal.cs:314)
PixelCrushers.SaveSystem:ApplySavedGameData (PixelCrushers.SavedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:871)
PixelCrushers.SaveSystem/<LoadSceneCoroutine>d__135:MoveNext () (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:1001)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)



I do have a quest with that ID, what do you think the error might be? Or how should I register it with Quest Machine?

I am using the action script I mention earlier to asign the quests. Thank you!
DiegoGary25
Posts: 9
Joined: Wed Mar 05, 2025 11:42 am

Re: Problems with save system.

Post by DiegoGary25 »

Also, If I am using a custom save manager, is there any documentation on how to only save the player's quest journal, i've been trying some approaches but they seem to not work. Or do you think this might be too complex?

Code: Select all

        public QuestJournalData SaveQuestJournalData()
        {
            QuestJournalData data = new QuestJournalData();
            foreach (var quest in questList)
            {
                var questState = quest.GetState();

                if (questState == QuestState.Active ||
                    questState == QuestState.Successful ||
                    questState == QuestState.Failed)
                {
                    QuestRecord record = new QuestRecord();
                    record.id = quest.id;              // Store ID only.
                    record.state = questState;         // Store quest's overall state.

                    data.questRecords.Add(record);
                }
            }
            return data;
        }


        public void LoadQuestJournalData(QuestJournalData data)
        {
            if (data == null) return;

            // Remove all existing quests properly:
            DestroyQuestInstances();

            // Recreate brand-new Quest objects from data:
            foreach (var record in data.questRecords)
            {
                // 1) Look up the "original" quest asset by ID:
                var originalQuestAsset = QuestMachine.GetQuestAsset(record.id);

                // 2) Clone the asset to get a fresh instance:
                var newQuest = originalQuestAsset.Clone();

                // 3) Restore the recorded state:
                newQuest.SetState(record.state);

                // 5) Add the new quest to this journal/container:
                AddQuest(newQuest);
            }

            // Finally, update the UI:
            RepaintUIs();
        }
        
User avatar
Tony Li
Posts: 23272
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems with save system.

Post by Tony Li »

Hi,

Make sure you've added all of your quests to a quest database asset. Assign that quest database to your Quest Machine GameObject.

For custom save managers, please see: How To: Use Save System with other save system assets
Post Reply