Page 1 of 1

Weird problem with number variable

Posted: Sat Sep 07, 2019 10:37 am
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

Re: Weird problem with number variable

Posted: Sat Sep 07, 2019 3:37 pm
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.

Re: Weird problem with number variable

Posted: Sat Sep 07, 2019 3:45 pm
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.

Re: Weird problem with number variable

Posted: Sat Sep 07, 2019 6:41 pm
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.

Re: Weird problem with number variable

Posted: Sat Sep 07, 2019 9:00 pm
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.