Page 1 of 1
Best way to deal with Loading / Saving
Posted: Thu Oct 02, 2014 11:39 pm
by andrew2110
Am getting very close to being able to wrap up my game now. I'm looking into the best way of loading and saving the Dialogue System state. My save game system works with EasySave and Parse (for cloud stored saved games).
I did have some examples of code for this but then it looked horrendous on here when I tried to copy and paste it, I guess I'm really just asking for an easy way to iterate through all Lua variables.
Edit: I think it's ok to delete this thread now. I'm just going to keep a track of when Lua variables are changing and only store things when they change.
Best way to deal with Loading / Saving
Posted: Fri Oct 03, 2014 1:05 am
by andrew2110
Actually, I've been looking for a way to iterate through all quests for a while now and not yet been able to find any way of doing it just yet.
I'll just need to save quests where quest states are not "unassigned" I think. I can see in the assembly browser that there's a way to do this and it's used by the QuestLog classes, but haven't been able to figure this out just yet.
Best way to deal with Loading / Saving
Posted: Fri Oct 03, 2014 3:32 am
by Tony Li
Hi Andrew,
There happens to be a FAQ specifically on saving the Dialogue System state with Easy Save. If you want to use it, the code would be just one line:
ES2.Save(PersistentDataManager.GetSaveData(), "myFile.txt?tag=dialogueSystem");
To get all quests, call QuestLog.GetAllQuests():
string[] questNames = QuestLog.GetAllQuests(QuestState.Active|QuestState.Success|QuestState.Failure);
Or you can grab the Lua Quest[] table and iterate through it manually. The code below returns a LuaTableWrapper, which is a layer that isolates you from the actual Lua implementation's table.
LuaTableWrapper questTable = Lua.Run("return Quest").AsTable;
foreach (var questName in questTable.Keys) {
LuaTableWrapper quest = questTable[questName] as LuaTableWrapper;
Debug.Log(questName + " state: " + quest[State]);
}
Best way to deal with Loading / Saving
Posted: Sat Oct 04, 2014 5:54 am
by andrew2110
Oh thats awesome, so sorry I missed that on the FAQ! Thats perfect