Announcement

Collapse
No announcement yet.

Calculating a vendor currency transaction

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    Click image for larger version

Name:	currency.jpg
Views:	1
Size:	333.8 KB
ID:	1205401
    Last edited by unit23; 01-13-2017, 05:35 AM.
    LEGENDS of EPICA [Twitter] [Facebook] [YouTube] [Vimeo]

    #2
    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.
    Last edited by HavocX; 01-13-2017, 07:05 AM.

    Comment


      #3
      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.

      Comment


        #4
        Originally posted by HavocX View Post
        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.
        Well, like often i think too complicated 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.
        LEGENDS of EPICA [Twitter] [Facebook] [YouTube] [Vimeo]

        Comment


          #5
          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.

          Comment

          Working...
          X