Managing Shared Variables

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pixelshiro
Posts: 3
Joined: Tue Apr 22, 2025 5:23 am

Managing Shared Variables

Post by pixelshiro »

Hi, would like to know how can I set the variable values?
Currently, I have an enum file which keeps track of the variables and retrieve them at runtime as such.

Code: Select all

// PixelCrushers.DialogueSystem.Variable (snippet)
public List<Variable> Variables = DialogueManager.DatabaseManager.DefaultDatabase.variables;

public enum Variables
{
    Alert,
    FirstTutorial
}
public Variable GetVariable(Variables v)
{
    return Variables.Find(x => x.Name == v.ToString());
}

private void test()
{
    Debug.Log(GetVariable(Variables.FirstTutorial).InitialBoolValue); // get
    GetVariable(Variables.FirstTutorial).InitialBoolValue = false; // set
}
While I could retrieve the values successfully, I don't know how to set its value? Or is there a better approach?
User avatar
Tony Li
Posts: 23254
Joined: Thu Jul 18, 2013 1:27 pm

Re: Managing Shared Variables

Post by Tony Li »

Hi,

At runtime, think of the dialogue database as read-only.

When the Dialogue System starts, it creates Lua variables for each of the dialogue database variables. To get and set them, use DialogueLua.GetVariable() and DialogueLua.SetVariable().
Post Reply