Dialogue System Trigger & Quests or Story Progression

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger & Quests or Story Progression

Post by Tony Li »

Hi,

To check if a quest state use QuestLog.GetQuestState().

To check a variable, use DialogueLua.GetVariable(). Since Lua variables can be any type, use one of these properties at the end of GetVariable() to specify the type of variable: asBool, asInt, asFloat, or asString.

You can also use [QuestPopup] and [VariablePopup] attributes to make the inspector use popup menus for quest and variable fields.

Here's an example:

Code: Select all

[QuestPopup] public string requiredQuest;
 public QuestState requiredQuestState = QuestState.Success;
 
 [VariablePopup] public string requiredVariable;
 public bool requiredVariableValue = true;
 
 public string destinationScene;
 public string spawnpoint;
 
 public bool AreRequirementsMet()
 {
    return (requiredQuest == "" || QuestLog.GetQuestState(requiredQuest) == requiredQuestState) &&
        (requiredVariable == "" || DialogueLua.GetVariable(requiredVariable).asBool == requiredVariableValue));
 }
 
 public void TryUseDoor()
 {
     if (AreRequirementsMet())
     {
         PixelCrushers.SaveSystem.LoadScene(destinationScene + "@" + spawnpoint);
     }
     else
     {
         DialogueManager.ShowAlert("You can't use this door yet.");
     }
 } 
Post Reply