Variable name not updated in dialogue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
zeroxpy
Posts: 12
Joined: Tue Oct 20, 2020 10:50 pm

Variable name not updated in dialogue

Post by zeroxpy »

I tried to use DialogueLua.GetVariable to change my variable, but it doesn't change the value in "Dialogue System -> Variable", even though it seems to work by looking at the console output:

Below is my code and console output:

Debug.Log(DialogueLua.GetVariable("PlayerName").asString);
//console output: Name
DialogueLua.SetVariable("PlayerName", "123");
Debug.Log(DialogueLua.GetVariable("PlayerName").asString);
//console output: 123

However, after running the code above, in Dialogue System "PlayerName" remains "Name". In addition, the next a few lines which use [var=PlayerName] all give me "Name" instead of "123". Am I missing something?

Thank you!
Attachments
PlayerName.PNG
PlayerName.PNG (2.98 KiB) Viewed 163 times
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Variable name not updated in dialogue

Post by Tony Li »

Hi,

The Dialogue Editor's Variables tab shows the Initial Value of the variable, not its current value.

To see the current value, use the Dialogue Editor's Watches tab or the separate Variable Viewer window. A quick way to open the Variable Viewer window from the Dialogue Editor's Variables tab is to select Menu > Variable Viewer. The other way to open the Variable Viewer is to select menu item Tools > Pixel Crushers > Dialogue System > Tools > Variable Viewer.
zeroxpy
Posts: 12
Joined: Tue Oct 20, 2020 10:50 pm

Re: Variable name not updated in dialogue

Post by zeroxpy »

Hi Tony,

Thank you for letting me know about this function. This is quite handy.

I realized that after a variable is changed (in runtime), the line that is already linked to would still use the previous value of the variable. The rest of the conversation would use the new value.

I think I am OK now. Thank you for the quick reply.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Variable name not updated in dialogue

Post by Tony Li »

Happy to help!
Post Reply