Calculating a vendor currency transaction

So i’m working on a vendor system and was wondering if there is a prefered way to calculate different currencies and how to handle them.

What i currently have are 3 currencies, which i convert to a single float, then subtract the transaction amount. But now i am not entirely sure what the best way is to split the float back to the separate currencies. Ideas are welcome, thanks.

Is it really necessary to store the three coin types separately in the first place? Do you have a carrying limit in total coins? Different exchange rate depending on location?

If not, just store coins and costs as one value and display it as G-S-B in the GUI.

If there are differences, buying from a vendor will be a complicated matter.

If you want to convert single value to G-S-B:

  1. Divide by ten and truncate to get gold.
  2. Subract gold from total and truncate to get silver.
  3. Subtract silver from remaining total and multiply by 10 to get bronze.

This can be used for displaying wealth and costs in the GUI or if you for some weird reason still want to convert back and forth all the time.

Well, like often i think too complicated :slight_smile: Thanks for pointing this out HavocX, that sounds like a good idea!

So basically i just need 1 float value, and then need a single function for displaying the different coin types.

Yes. I suggest creating a pure (no execution pin) function “To Coins” in a blueprint function library. One float pin in for the total and three int outputs for the coins.