Weird problem with number variable

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Weird problem with number variable

Post by lostmushroom »

Hey, I have an issue with a number variable that I can't figure out.

I have a variable "Gold", which I set to 3. I then have a dialogue entry: "Here's a bag of gold", which should be available whenever your Gold variable is equal or greater than 1.

The condition on the dialogue entry is:

Variable["Gold"] >=1

And the script is:

Variable["Gold"] = Variable["Gold"] - 1

However, when I tested this, for some reason is is deducting 2 Gold each time you pick that dialogue entry.

Have I made a really obvious mistake or is something weird going on? :D
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Weird problem with number variable

Post by Tony Li »

Is it possible that a prior node is also decrementing Gold? Temporarily set the Dialogue Manager's Debug Level to Info. This should log all of the Script fields that nodes run.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Weird problem with number variable

Post by lostmushroom »

Not that I can see. I made a fresh conversation with only one node and got the same thing. Doesn't look like anything unusual showing up in info, either.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Weird problem with number variable

Post by Tony Li »

Maybe something outside the conversation is changing the value of "Gold"?

You're not assigning a string value to the variable are you? Like:

Code: Select all

Variable["Gold"] = "3"
It's a long shot, but it's happened before.

If you get totally stuck, please feel free to send me an example scene or reproduction steps.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Weird problem with number variable

Post by Tony Li »

The player response menu button was clicking itself twice. The Dialogue System automatically assigns an event handler to the button's OnClick() event. You don't need to assign the event yourself. By doing so, it caused the response to play twice.
Post Reply