Calculating Multiple Currencies?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Gryphbear
Regular
Posts: 84
Joined: Wed Jun 16, 2010 11:45 pm
Contact:

Calculating Multiple Currencies?

#1 Post by Gryphbear » Mon Jul 09, 2018 4:30 pm

Alright. I am sort of stumped. I tested out this feature from this thread for calculating different 'currencies' - viewtopic.php?f=8&t=48109&p=477537&hili ... es#p477537

My question is - I do not want to show that I have a "possible" amount for all of the different coinages. Just 2-3 types of coins out of 5, but I want to make sure all of them are included, in case I decide to make the rarest coin available to my funds. My character in my VN is going to be doing shopping, eventually, and There's six different coin currencies. But the character will probably not get the 'rarer' currencies. So, I was wondering if there was an alternate way to maybe calculate a certain set?

For example: My character will probably deal with Copper Coins, Gold/Silver, and an occasional Steel. In this universe, steel is more rarer/valued than gold. I want to make sure the character is actually 'getting' their change if they pay with a higher valued coin, but this method just feels like I'm just re-arranging the coin values into the different values.

Code: Select all

$ cp_funds = 1000
    
    $ renpy.say(None, "I have {0} Platinum, {1} Steel, {2} Iron, {3} Silver, {4} Gold, and {5} Copper Pieces.".format(cp_funds / 500, cp_funds / 100, cp_funds / 10, cp_funds / 5, cp_funds / 0.4, cp_funds))
    $ cp_funds +=500
    $ renpy.say(None, "I have {0} Silver pieces.".format(cp_funds / 5))
    $ renpy.say(None, "I have {0} Steel, or {1} Copper pieces.".format(cp_funds / 100, cp_funds))
As the code shows above, you can probably selectively 'pick' which 'funds' you want to showcase, but... I was wondering if there were a simpler way? Like assign variables, or...? something?

If you have questions, just ask :) I'll try to clarify things if I can.
WIP: Ring av Guder - (Contemporary Fantasy VN/Dating Sim?)

What do you get when you inherit a mystical ring, meet Norse Dieties, and Werewolves, Satyrs, or Dwarves? Possibilities.

General Completion: 5% - (Still working on story plot.)
Story status: 1% (In progress of revamping)
Scripting: 1% (Prologue is about done)
Character Art: 0% (Would like to find a Bara-type Artist, but will learn to draw them myself if necessary)
BG/CG's: 0% (None so far)

User avatar
namastaii
Miko-Class Veteran
Posts: 954
Joined: Mon Feb 02, 2015 8:35 pm
Projects: What Life; Barakana, Truth Beneath the Rose, Water Girl
Organization: Koompire, Clockwork Cafe
Github: namastaii
Skype: Discord: lunalucid#7684
Soundcloud: deadseed
Location: USA
Contact:

Re: Calculating Multiple Currencies?

#2 Post by namastaii » Wed Jul 11, 2018 2:01 pm

Maybe I'm misunderstanding (because I'm a little confused - probably not your fault lol) but instead of having all coin types under one variable, would it be simpler to have a variable for each coin type and then another variable that represents them added up? Or am I totally off of what you're trying to do?

Basically cp_funds equals steel, iron, silver, gold, and copper coins added up and each have their own variable so you can keep track of each one and how much they're worth etc

User avatar
Remix
Miko-Class Veteran
Posts: 831
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I cannot draw very well)
Projects: An un-named 3d anime based trainer game
Contact:

Re: Calculating Multiple Currencies?

#3 Post by Remix » Wed Jul 11, 2018 3:08 pm

I would actually advise against trying to separate wealth and coins...

For the programming math it really is easiest to just store lowest denomination... after all £13 52p is 1352p so why store the values apart. Evaluating whether a player can afford a sword is easier too if sword is just a set number of the lowest denomination.

If you really want to add Silver Coins I would suggest making them something like Krugerrands or Doubloons ... not directly usable as money just they can be sold for high prices to the right people. You could even make a side quest after the person finds one, to find a buyer...

User avatar
Gryphbear
Regular
Posts: 84
Joined: Wed Jun 16, 2010 11:45 pm
Contact:

Re: Calculating Multiple Currencies?

#4 Post by Gryphbear » Wed Jul 11, 2018 7:30 pm

Thank you for the feedback. It does look like I'll have to at least keep track of their funds - converting CP (lowest value) to Silver, or Steel, etc. in code/in game. And as for Silver - this game is going to be set in the universe of Dragonlance, so I can't exactly call them Krugerrands/Doubloons, but thanks for the suggestion :)
WIP: Ring av Guder - (Contemporary Fantasy VN/Dating Sim?)

What do you get when you inherit a mystical ring, meet Norse Dieties, and Werewolves, Satyrs, or Dwarves? Possibilities.

General Completion: 5% - (Still working on story plot.)
Story status: 1% (In progress of revamping)
Scripting: 1% (Prologue is about done)
Character Art: 0% (Would like to find a Bara-type Artist, but will learn to draw them myself if necessary)
BG/CG's: 0% (None so far)

Post Reply

Who is online

Users browsing this forum: No registered users