How to check if player have enough coins in dialogue system

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
PepeJEe
Posts: 18
Joined: Sat Apr 24, 2021 8:39 am

How to check if player have enough coins in dialogue system

Post 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!
mcfurgerburger
Posts: 12
Joined: Thu May 26, 2022 11:33 am

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

Post 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.
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
PepeJEe
Posts: 18
Joined: Sat Apr 24, 2021 8:39 am

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

Post by PepeJEe »

Awesome, thank you! :D
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply