Can't acces dialogue system variables on runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ZeroElementGames
Posts: 13
Joined: Tue May 25, 2021 7:18 pm

Can't acces dialogue system variables on runtime

Post by ZeroElementGames »

Hi Tony,
we have an issue with the dialogue system, variables. We want to check the value of some variables to activate or deactivate some icons on our menus.
We're trying to access the variables we have in the database that is in our game manager and In order to do that, we access the database manager that the dialogue system controller has and we store the default database in a variable.
With that stored database we want to access some variables and check their values to know whether if we have to set some buttons active or not. In order to achieve that we iterate that array and we look the int that the database has stored for those variables.
The problem is that those variables, have always the same value, even though we are changing their values. This changes are reflected on the watches table that we can look at in Unity but we don't know how to access it through C# code. We'd like to know how should we access those variables that are stored in the database.
Thanks for everything!
Attachments
code.png
code.png (47.01 KiB) Viewed 342 times
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't acces dialogue system variables on runtime

Post by Tony Li »

Hi,

At runtime, think of the dialogue database itself as static. At start, the Dialogue System loads dialogue database variables into its Lua environment where you can manipulate them however you want. The Dialogue Editor window's Watches tab shows the Lua variable values. You can get and set the Lua variable values in C# using the DialogueLua class. Example:

Code: Select all

int someValue = DialogueLua.GetVariable("Some Variable").asInt;
DialogueLua.SetVariable("Some Variable", someValue + 1);
(More about the Dialogue System's Lua environment here.)
ZeroElementGames
Posts: 13
Joined: Tue May 25, 2021 7:18 pm

Re: Can't acces dialogue system variables on runtime

Post by ZeroElementGames »

Hi Tony,

Thank you for the answer, and sorry for the late response, we are pretty bussy right now!
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't acces dialogue system variables on runtime

Post by Tony Li »

No worries; glad to help!
Post Reply