Good day,
I'm having a challenge validating a condition through the dialogue editor: Quest["Find_something_to_kindle_fire"].State == "unassigned", which does not trigger at all. If I remove the condition, the quest works. I have tried to check the initial state of the quest by using QuestLog.GetAllQuests (QuestState.Unassigned) and the quest returns as such. I'm on a tight deadline so at this point I'm wondering a few things:
- How come I can't use the drop down box in the dialogue editor (Quest tab) to select any other state than none;
- Why does the quest return as "unassigned' through QuestLog.GetAllQuests and yet, why it doesn't comply with the condition?
Finally, I have implemented lua variable watching but it only shows me when the quest gets set to new.
And finally, I find that debugging and tracing lua code is very difficult, so I am looking at hooking my dialogs through C# code, that is, being able to use custom functions which would handle conditions so it's easier to trace what's doing what. Any pointers on the best way to do this?
Thanks a lot for your ongoing support,
-Jeff
How to set the, intial state of a Quest (and other related thoughts)
Re: How to set the, intial state of a Quest (and other related thoughts)
Hi Jeff,
If it doesn't show "unassigned" exactly, it's probably related to the first problem above. I suspect a conflict is preventing the Dialogue System from setting quest states properly. Are there any errors in the Console window?
This is just FYI so you don't try to register functions with the same names. Here's an example script that registers a function ChangeQuestState(). This function changes a quest state and logs the change to the Console window:
Since you're under a tight deadline, please feel free to email me directly at tony (at) pixelcrushers.com any time. I'll also keep a close eye on the forum to reply back here.
In the Dialogue Editor, the dropdown should also contain "unassigned", "active", "success", etc. If you import the Dialogue System into a new, empty project, does the dropdown work correctly? This will tell us if the problem is caused by a conflict in your current project.Hyrad wrote:- How come I can't use the drop down box in the dialogue editor (Quest tab) to select any other state than none;
What happens if you add a Lua Console to the scene, press ~+L to open it, and enter this:Hyrad wrote:- Why does the quest return as "unassigned' through QuestLog.GetAllQuests and yet, why it doesn't comply with the condition?
Code: Select all
return Quest["Find_something_to_kindle_fire"].State
Yes, register your C# code as Lua functions. From version 1.5.9 on, the Dialogue System registers 4 functions that are wrappers around the QuestLog class: (more info here)Hyrad wrote:And finally, I find that debugging and tracing lua code is very difficult, so I am looking at hooking my dialogs through C# code, that is, being able to use custom functions which would handle conditions so it's easier to trace what's doing what. Any pointers on the best way to do this?
- CurrentQuestState(questName)
- CurrentQuestEntryState(questName, entryNumber)
- SetQuestState(questName, state)
- SetQuestEntryState(questName, entryNumber, state)
Code: Select all
CurrentQuestState("Find something to kindle fire") == "unassigned"
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MyQuestFunctions : MonoBehaviour {
void OnEnable() {
Lua.RegisterFunction("ChangeQuestState", this, typeof(MyQuestFunctions ).GetMethod("ChangeQuestState"));
}
void OnDisable() {
Lua.UnregisterFunction("ChangeQuestState");
}
public void ChangeQuestState(string questName, string newState) {
var oldState = QuestLog.CurrentQuestState(questName);
Debug.Log("CHANGING QUEST " + questName + " STATE FROM " + oldState + " TO " + newState);
QuestLog.SetQuestState(questName, newState);
}
}
Re: How to set the, intial state of a Quest (and other related thoughts)
Hi Tony, as always, thanks for going beyond the call of duty on this one. I just created a new quest and now that I can set the initial state it works.
As a side note, I just saw that I had a second dialog for the NPC which was not being found even though it existed (or at least it was showing up in the dialogue editor). I created a new one and the new one works fine. Sorry I cannot provide you with more specific info, but I'm including it in case it helps.
For the first part, I deleted the assets directory, re-imported it and restarted Unity. The good news is that if I create a new quest i get to set the intial state; the bad news is that the quest I was trying to debug previously just dissapeared from the database. It's not too bad, I mean I can just re-create it (and this might be related directly or indirectly to the fact that I just updated the dialogue system) but I would like to avoid such a situation in the future. So I think for more safety I will export my database to CSV, would that be a viable solution to ensure that I make a backup?In the Dialogue Editor, the dropdown should also contain "unassigned", "active", "success", etc. If you import the Dialogue System into a new, empty project, does the dropdown work correctly? This will tell us if the problem is caused by a conflict in your current project.
As a side note, I just saw that I had a second dialog for the NPC which was not being found even though it existed (or at least it was showing up in the dialogue editor). I created a new one and the new one works fine. Sorry I cannot provide you with more specific info, but I'm including it in case it helps.
Thanks for this information as well. I will use it to build my own quest system in the near futureYes, register your C# code as Lua functions.
Last edited by Hyrad on Tue Mar 14, 2017 3:50 pm, edited 1 time in total.
Re: How to set the, intial state of a Quest (and other related thoughts)
Hi,
Updating your version of the Dialogue System shouldn't cause any issues, as the dialogue database format hasn't changed in a long time. But it sure doesn't hurt to make backups. CSV or Chat Mapper XML formats are both fine to make backups. You don't need Chat Mapper itself if you're just using it as a backup format.
Updating your version of the Dialogue System shouldn't cause any issues, as the dialogue database format hasn't changed in a long time. But it sure doesn't hurt to make backups. CSV or Chat Mapper XML formats are both fine to make backups. You don't need Chat Mapper itself if you're just using it as a backup format.
Re: How to set the, intial state of a Quest (and other related thoughts)
Ok, my trouble started when I tried to re-import the database, but I made a lot of manipulations so perhaps it's just me. Thanks for the info.