Page 1 of 1

How to check if player have enough coins in dialogue system

Posted: Thu May 26, 2022 10:12 am
by PepeJEe
So I have a small conversation where an NPC asks for certain amount of coins, so I can get into town. So in the response menu panel i want to click "I have enough coins" if my coinAmount is over the required amount. But If I don't have enough coins that response menu button would be disabled. How can I do that exactly? I have public "coinAmount" int in my playermanager which stores the amount of coins that I have.

-Best wishes, Pepe!

Re: How to check if player have enough coins in dialogue system

Posted: Thu May 26, 2022 11:37 am
by mcfurgerburger
you're probably gonna need to create a custom lua method that goes to your playermanager to check the coins. set that as the condition, i.e.:

HasCoinAmount(800) == true

where the HasCoinAmount method is the custom lua method defined in your template script and it takes a double parameter that is checked against coinAmount in playermanager.

Re: How to check if player have enough coins in dialogue system

Posted: Thu May 26, 2022 1:06 pm
by Tony Li
^ What he said. :-)

The condition will be in the response entry node's Conditions field.

By default, responses whose Conditions are false (i.e., "invalid" responses) will not appear in the response menu. To make invalid responses appear in the menu, tick the Dialogue Manager GameObject's Display Settings > Input Settings > Include Invalid Entries checkbox. You can also specify an [em#] Tag For Invalid Responses and set the appearance of that [em#] Tag in the Dialogue Editor's Database section.

To conditionally show only specific invalid entries, see How To: Do Skill Checks In Conversations.

Re: How to check if player have enough coins in dialogue system

Posted: Thu May 26, 2022 7:30 pm
by PepeJEe
Awesome, thank you! :D

Re: How to check if player have enough coins in dialogue system

Posted: Thu May 26, 2022 7:44 pm
by Tony Li
Glad to help!