Variable doesn't get set correctly

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Variable doesn't get set correctly

Post by F1foux »

Hi Tony,

I created a variable "Room_Interactions" in the Dialogue Manager. I have 2 conversations in my game and at a certain point I add 1 to the created variable: Variable["Room_Interactions"] = Variable["Room_Interactions"] + 1;

After that dialogue entry I created another node with the condition: Variable["Room_Interactions"] >= 2
So these nodes only get triggered if the player had both Conversations so the variable is 2. But for some reason it gets triggered every time.

Is there a way to see when a Variable gets changed? It doesn't get updated at runtime in the manager itself even when I check the "Watchers" checkmark.

What am I doing wrong?

Thank you for your help!
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Variable doesn't get set correctly

Post by Tony Li »

Hi,

You can watch the runtime value of a variable in the Watches tab or Variable Viewer window.

In the Watches tab, select Menu > Add Runtime Variable -- or Add All Runtime Variables if you want to watch them all. Tick Auto Refresh to make the Watches tab automatically refresh the display of the variables' values.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Variable doesn't get set correctly

Post by F1foux »

Thank you. Now I could check the variable change at runtime and I saw that it changes from 0 to 2 eventhough my script tells it to add 1: Variable["Interactions"] = Variable["Interactions"] + 1

Do you have any idea how this could happen?
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Variable doesn't get set correctly

Post by Tony Li »

Is the code running twice, perhaps in two entries?

Temporarily set the Dialogue Manager's Other Settings > Debug Level to Info, This will log Dialogue System activity to the Console. You can trace through to see when the variable changes.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Variable doesn't get set correctly

Post by F1foux »

I fixed it by putting the variable update at the start of the conversation. In the end of the dialogue it could branch in two directions and in both the variable would be updated... it's weird thought that it triggered two times even though the player could only go down one branch.

As long as it works now I'm happy.

Thank you for your help!
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Variable doesn't get set correctly

Post by Tony Li »

Was the code on your <START> node? If a Dialogue System Trigger's Actions > Start Conversation > Skip If No Valid Entries is ticked, it has to run the <START> node to determine if any of its children are currently valid. If it then starts the conversation, it will run the <START> node again as part of the actual conversation.
Post Reply