[HOWTO] How To: Save Quest Journal Without Save System

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Save Quest Journal Without Save System

Post by Tony Li »

If your project already uses a different save system and you only want to save the current state of the player's quest journal, use QuestJournal.RecordData(). This returns a string representation of the quest journal's quests and their states. To restore the quests, use QuestJournal.ApplyData().

If you don't already have a reference to the Quest Journal component, use QuestMachine.GetQuestJournal().

Example:

Code: Select all

string s = QuestMachine.GetQuestJournal().RecordData(); // Your own save system can now save string 's'.
and

Code: Select all

QuestMachine.GetQuestJournal().ApplyData(s);
---

If you want to save all Quest Machine data, including not only the Quest Journal but also Quest Givers, Spawners, etc., you can use the full save system to record and apply the data. However, instead of calling SaveSystem.SaveToSlot(#) to save to permanent storage, use these methods to record the save data to a string and restore it from a string:

Code: Select all

string s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
and

Code: Select all

SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(s));
Post Reply