My player collects coins as ints (coins) that are then converted to strings (coinsCount) for the text in the UI
Basically is there a way to access these ints with a "Manual Enter" condition on a dialogue node within a conversation?
Some condition like, (Player, coins >= 50) then it will show the "Purchased" dialogue node option
But if (Player, coins < 50) it will show the "You don't have enough coins" option
Thank you for any suggestions.
Conditions; Checking if Player Has Enough Coins
-
- Posts: 60
- Joined: Thu Mar 24, 2022 12:07 am
Re: Conditions; Checking if Player Has Enough Coins
Hi,
There are two ways you could do this:
1. Dialogue System variable: Whenever you set the value of coins, also set a parallel Dialogue System variable (e.g., also called "coins"). Example:
Then you can check the variable value in
2. C# method: Write a C# method that returns the value of coins:
Then register that method with Lua (tutorial) and use it in Conditions:
There are two ways you could do this:
1. Dialogue System variable: Whenever you set the value of coins, also set a parallel Dialogue System variable (e.g., also called "coins"). Example:
Code: Select all
public void CollectCoin()
{
coins++; // Increment coins by 1.
DialogueLua.SetVariable("coins", coins); // Set DS variable to same value.
}
- Dialogue Text: "Sorry, you don't have enough coins. You need at least 3."
- Conditions: Variable["coins"] < 3
2. C# method: Write a C# method that returns the value of coins:
Code: Select all
public double GetCoinCount()
{
return coins;
}
- Dialogue Text: "Sorry, you don't have enough coins. You need at least 3."
- Conditions: GetCoinCount() < 3
-
- Posts: 60
- Joined: Thu Mar 24, 2022 12:07 am
Re: Conditions; Checking if Player Has Enough Coins
I used the first option and it worked perfectly. Thank you!
Re: Conditions; Checking if Player Has Enough Coins
Glad to help!