Hi Tony,
Finally have some time to look at fixing some minor bugs with the save system's integration into my project. In particular, I'm looking to fix the active quest not displaying properly in my save metadata info.
I don't have the code in front of me right now but the basic gist of it is that I'm trying to check first the group field of the quest (this works as a simple GetFieldValue method) and then check the state is active(this is the part I'm having issues with). There's only one active quest a time in the group.
Is there a GetField equivalent to the enum field used by the quest state? If I can use something similar or a different method to get the state it should be an easy fix. Or perhaps I'm looking at this the wrong way.
Let me know if this sounds doable to you - I'll try to get my hands on the relevant code tomorrow if it'll help.
Thanks!
FindValue for enum Fields
Re: FindValue for enum Fields
Hi,
When saving a game and pulling info into your metadata object, you can use the QuestLog class.
Methods that might be useful to you are:
When saving a game and pulling info into your metadata object, you can use the QuestLog class.
Methods that might be useful to you are:
- QuestLog.GetQuestState("quest")
- QuestLog.GetQuestGroup("quest")
- QuestLog.GetAllQuests(), GetAllGroups(), and GetAllQuestsAndGroups()
- QuestLog.StateToString() and StringToState()
Tip for pulling info not in metadata
Tip: If the info isn't in your metadata info and you need to pull it straight from the Dialogue System's saved data in an existing saved game, you can read the saved data, temporarily fill the Dialogue System's Lua environment with the Dialogue System data, and then use QuestLog, or use Lua.Run() to read it directly.
Example:
Example:
Code: Select all
SavedGameData savedGameData = SaveSystem.storer.RetrieveSavedGameData(slotNumber);
var dsData = savedGameData.GetData("DS key"); // Assumes Dialogue System Saver's key is "DS Key".
PersistentDataManager.ApplySaveData(dsData);
foreach (string quest in QuestLog.GetAllQuests()) // Loop through all active quests.
{
string group = QuestLog.GetQuestGroup(quest);
// Do something with 'quest' and 'group'.
}
-
- Posts: 111
- Joined: Mon Apr 08, 2019 8:01 am
Re: FindValue for enum Fields
Hey Tony,
Thanks for the tips - was able to get this to work using the code below:
Do you reckon this'll lead to any problems if I have a lot of main and side quests implemented?
Thanks for the tips - was able to get this to work using the code below:
Code: Select all
foreach (var quest in DialogueManager.masterDatabase.items)
{
if (quest.IsItem) continue;
if (quest.LookupValue("Group") == "Main" && QuestLog.GetQuestState(quest.Name) == QuestState.Active)
{
activeQuest = quest.Name;
return quest.Name;
}
}
return null;
Re: FindValue for enum Fields
Hi,
That's fine, and performance should be fine. If you're going to be creating new quests at runtime, loop through QuestLog.GetAllQuests() instead of DialogueManager.masterDatabase.items. But if you know that the only quests will be the ones defined in the database, your code is more performant.
That's fine, and performance should be fine. If you're going to be creating new quests at runtime, loop through QuestLog.GetAllQuests() instead of DialogueManager.masterDatabase.items. But if you know that the only quests will be the ones defined in the database, your code is more performant.