In this Tutorial we will display our Currency inside our Inventory.
I will use following Currencies:
Currency.Type.Bronze
Currency.Type.Silver
Currency.Type.Gold
Look inside these Tutorials, on how i’ve created those Currencies:
1. First of all we need to create our Widget Blueprint and add following to it:
Make a Horizontal Box and add following as Child:
Image Widget: Contains the Gold Icon
Text Widget: Contains the Gold Amount
Image Widget: Contains the Silver Icon
Text Widget: Contains the Silver Amount
Image Widget: Contains the Bronze Icon
Text Widget: Contains the Bronze Amount
If you are not sure how to set this up, you can look inside the SP8_WBP_Inventory, which can be found inside the Directory RPG_Essentials / Example / Widgets.
2. Now we can switch to the Event Graph and create the Function setCurrencyText, which will set the Values of the Currencies to the Widget.
Inside this Function you should do following:
Make following Inputs:
Currency Type [Gameplay Tag]
Value [Integer]
Create a switch on the Currency Type and add all Currency Gameplay Tags to it.
Now we can set the Value to the correct Text Widget, depending which Currency Type currently is changing.
3. Create inside the Event Graph a new Event and call it InitializeCurrencyComponent and do following:
Add as Input the Currency Component
Bind the Event Currency Changed to it
On the Event Pin call Create Event and set the Function to setCurrencyText.
After that we can call getAllCurrencies on the Currency Component and loop trough all Keys and Values and call SetCurrencyText on it.
The Event InitializeCurrencyComponent should be called, when the Stat Component was already Initialized.
If you call it before, you will get wrong Values.