Announcements, support questions, and discussion for the Dialogue System.
-
megadok
- Posts: 54
- Joined: Sat Sep 05, 2020 12:04 pm
Post
by megadok »
Hey Tony!
I would like to know how I can change the value of a variable in my database.
I have tried...
Code: Select all
myDatabase.variables[0].InitialValue = "megadok";
It work.
But i need something like this...
Code: Select all
myDatabase.setVariable("variableName")="anything";
Thank you!
-
Tony Li
- Posts: 22051
- Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li »
Hi,
At runtime, variable values are stored in
Lua. Use the
DialogueLua class to get and set variables:
Code: Select all
DialogueLua.SetVariable("X", 42);
Debug.Log("X is " + DialogueLua.GetVariable("X").asInt);
-
megadok
- Posts: 54
- Joined: Sat Sep 05, 2020 12:04 pm
Post
by megadok »
I did:
Code: Select all
PixelCrushers.DialogueSystem.DialogueLua.SetVariable("Alert","anything");
Code: Select all
Debug.Log("Your word is " + PixelCrushers.DialogueSystem.DialogueLua.GetVariable("Alert").ToString());
Console said me:
Code: Select all
Your word is PixelCrushers.DialogueSystem.Lua+Result
What is the problem?
Thanks!
-
megadok
- Posts: 54
- Joined: Sat Sep 05, 2020 12:04 pm
Post
by megadok »
Ok I solved it this way...
Code: Select all
Debug.Log("X is " + PixelCrushers.DialogueSystem.DialogueLua.GetVariable("Alert").luaValue.ToString());
Thank you Tony!
-
Tony Li
- Posts: 22051
- Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li »
That will work. A shortcut is:
Code: Select all
Debug.Log("X is " + PixelCrushers.DialogueSystem.DialogueLua.GetVariable("Alert").asString);