Page 1 of 1

Loading causes quest not found in DB error

Posted: Sat Oct 12, 2019 9:24 am
by Passero
I am trying to load a game I previously saved but I get an error upon loading:

Code: Select all

Quest Machine: Player Can't find quest mineOre. Is it registered with Quest Machine?
UnityEngine.Debug:LogError(Object, Object)
PixelCrushers.QuestMachine.QuestListContainer:ApplyData(String) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:356)
PixelCrushers.QuestMachine.QuestJournal:ApplyData(String) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestJournal.cs:174)
PixelCrushers.SaveSystem:ApplySavedGameData(SavedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:579)
GameManager:Awake() (at Assets/_Script/Managers/GameManager.cs:36)
I double checked and the quest DB that is registered with the Quest Machine game object does have the mineOre quest assigned to it...

Here's how I save and load:

Code: Select all

public void saveGame(string name)
    {
        storeScene();
        SaveGame game = new SaveGame();
        game.fullDB = fullDB;
        string s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
        game.questSystem = s;
        ES3.Save<SaveGame>("game", game,name);
    }
    
    
And here's how I load:

Code: Select all

if (loadFromFile != "") {
     Logger.log("LOAD", "Loading from file <b>" + loadFromFile + "</b>");
     SaveGame game = ES3.Load<SaveGame>("game", loadFromFile);
     fullDB = game.fullDB;
     SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(game.questSystem));
     loadFromFile = "";
}
When I start a new game (without loading), it works fine and I can initiate the quest without problems.

Not sure if it has something to do with it but the scene where I click a "Load" button, doesn't have the quest machine game object.
It doesn't need to as it's just the title screen with buttons.
The place where I execute the load logic is inside a scene that does have the QM game object so I don't think this is the issue, but just mention it... just in case.

Re: Loading causes quest not found in DB error

Posted: Sat Oct 12, 2019 10:03 am
by Tony Li
Hi,

Are you perhaps calling:

Code: Select all

SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(game.questSystem));
before the Quest Machine GameObject has had a chance to run its Awake method?

Re: Loading causes quest not found in DB error

Posted: Sat Oct 12, 2019 10:16 am
by Passero
mmm yes, that's a possibility.

I now moved the ApplySavedGameData to the start of my GameManager and that indeed seems to solve the problem.

Thx!

Re: Loading causes quest not found in DB error

Posted: Sat Oct 12, 2019 10:43 am
by Tony Li
Happy to help!