Creating UI tracker for variables

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Creating UI tracker for variables

Post by annathehank »

Hi again!

This time I'm trying to figure out how to create a UI system like the quest log window but one that stores variable information. For example, a window that would display information about people as you meet them. I have bool variables set up that are basically "person a met" that I set to true once the player has a conversation with them, and the description is information about that person. I was kind of trying to reverse-engineer the quest window UI in the basic pre-fab, but I can't seem to tell where the fields are gathering the quest information from the dialogue manager.

Are variables public? Is there a way to call them from other scripts? And if so, how?

Thank you!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating UI tracker for variables

Post by Tony Li »

Hi,

Yes, variables are public. You can get their current values using DialogueLua.GetVariable(). To enumerate all of the variables in your database, examine DialogueManager.masterDatabase.variables. Example:

Code: Select all

foreach (Variable variable in DialogueManager.masterDatabase.variables)
{
    if (variable.Type == FieldType.Boolean)
    {
        Debug.Log($"Variable[{variable.Name}] = {DialogueLua.GetVariable(variable.Name).asBool}");
    }
}
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Creating UI tracker for variables

Post by annathehank »

Ahh thank you so much! I knew they were stored somewhere I just wasn't sure where to look for them <3
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating UI tracker for variables

Post by Tony Li »

Glad to help!
Post Reply