Money??? please give advice
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.
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.
Money??? please give advice
I am working on a game wherein I'd like there to be a money system of some sort. I can see how I could use variables as money (and add or subtract it as needed), but how could I show the value of the variables to the player? Are there other ways to have money in a game? Any advice would be appreciated.
Re: Money??? please give advice
Taken directly from my own game:
Note the line which outputs the value of gold: "%(gold)d"
Ideally, you would have an inventory system also, but I'm not at a level where I'm willing make one.
Code: Select all
label purchasemiller:
menu:
"Buy Pork (50 Gold)":
if (gold >= 50):
play sound("change.ogg")
kneutral "Some ham and sausages please."
miller "Here you go."
$ yieldpork += 1
$ gold -= 50
else:
kneutral "Oh, I do not have enough money anymore for this item."
jump purchasemiller
"Buy Bread (20 Gold)":
if (gold >=20):
play sound("change.ogg")
kneutral "Some bread please."
miller "Right away, madam."
$ yieldbread += 1
$ gold -= 20
else:
kneutral "Oh, I do not have enough money anymore for this item."
jump purchasemiller
"Buy Cheese (35 Gold)":
if (gold >= 35):
play sound("change.ogg")
kneutral "I would like some cheese."
miller "Very well."
$ yieldcheese += 1
$ gold -=35
else:
kneutral "Oh, I do not have enough money anymore for this item."
jump purchasemiller
"Check Wallet.":
kneutral "It looks like I have %(gold)d Gold."
jump purchasemiller
"Stop Purchasing.":
ksmile "I better leave now before I run out of money."
return
Ideally, you would have an inventory system also, but I'm not at a level where I'm willing make one.
Re: Money??? please give advice
Do you mean you want the amount of money constantly shown, at the top or something? (Like, say, Zelda.)
Re: Money??? please give advice
This isn't the same guest that asked the question, but I would like to know how to get the total money up at the top. I tried "%(gold)d" in an ui.frame at the top, but it doesn't show the amount, it just shows "%(gold)d."
Re: Money??? please give advice
I don't know if this is what you're looking for, i'm using it for an in game clock in the game i'm working on, but this is what it'd look like if i wanted to do the same for money
Hope that helps some
Code: Select all
init:
$ text = 'MONEY'
$ curren = '$'
$ money = 537
init python:
show_money = True
def stats_overlay():
if not show_money:
return
stats_frame('Time', xalign=1.0, yalign=0.0)
config.overlay_functions.append(stats_overlay)
def stats_frame(name, **properties):
ui.frame(xfill=False, yminimum=None, **properties)
ui.hbox()
ui.vbox()
ui.text('%s' % (text), xalign=0.0, size=20)
ui.text('%s%02d' % (curren,money), xalign=0.0, size=25)
ui.close()
ui.close()
label start:
'Start'
$ money += 20
'Adding more money'
$ show_money = False
'Making the money displayable dissapear'
$ show_money = True
'And reappear'
'End'
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Money??? please give advice
That's because python statements don't automatically interpolate variables. Note in J13's code:Guest wrote:This isn't the same guest that asked the question, but I would like to know how to get the total money up at the top. I tried "%(gold)d" in an ui.frame at the top, but it doesn't show the amount, it just shows "%(gold)d."
Code: Select all
ui.text('%s%02d' % (curren,money), xalign=0.0, size=25)
Re: Money??? please give advice
This is the original guest, heh.
Thank you so much for your advice! I'm implementing the scripts right now. I really appreciate your help!! <3
Thank you so much for your advice! I'm implementing the scripts right now. I really appreciate your help!! <3
Re: Money??? please give advice
That's actually really great. I'm planning on using a temporary script like this as a debug tool for keeping track of the major emotional variables: I know there's probably some developer tool that lets us do that, but this feels more elegant.
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Money??? please give advice
Why make it "temporary"? That could be the developer tool.themocaw wrote:That's actually really great. I'm planning on using a temporary script like this as a debug tool for keeping track of the major emotional variables: I know there's probably some developer tool that lets us do that, but this feels more elegant.
Re: Money??? please give advice
I mean temporary as in, "Damned if I'm going to let the script stay in there for the final distribution, you young punks". Although, it might make a nice unlockable. Hmmm. . .Criptych wrote:Why make it "temporary"? That could be the developer tool.themocaw wrote:That's actually really great. I'm planning on using a temporary script like this as a debug tool for keeping track of the major emotional variables: I know there's probably some developer tool that lets us do that, but this feels more elegant.
-
- Regular
- Posts: 87
- Joined: Sat Jun 23, 2007 9:19 am
- Projects: ALICE.NET
- Location: The other end of the internet.
- Contact:
Re: Money??? please give advice
Point taken.themocaw wrote:I mean temporary as in, "Damned if I'm going to let the script stay in there for the final distribution, you young punks".
-
- Regular
- Posts: 42
- Joined: Fri Jun 15, 2007 9:45 am
- Location: Philly, USA
- Contact:
Re: Money??? please give advice
Hey, this is awesome as a debug tool. I tried a similar thing debugging with a ui bar, but I feel a digit value is much more useful for any game with hidden stats. Let me suggest the following changes/comments to the first init block to make it easier for new people to get...
Code: Select all
init:
$ statlabel = 'STRING'
# Replace 'STRING' with an appropriate label for the statistic, eg 'MONEY'
$ statprefix = 'STRING'
# Replace 'STRING' with an appropriate prefix for the statistic, eg '$' or '' for none
$ statvalue = 0
"HOLD ON TIGHT" ~ Outfits and expressions, where art thou? And why does Elsa's face look so awful??? *bangs head in*
Everytime you delete a traceback, someone else gets it. -PyTom
Everytime you delete a traceback, someone else gets it. -PyTom
Re: Money??? please give advice
This works EXTREMELY well.
-
- Regular
- Posts: 96
- Joined: Sun Jan 24, 2016 6:51 am
- Projects: undisclosed...
- Contact:
Re: Money??? please give advice
Hi everybody!
I've found this topic while trying to tweak my money displayable.
I think that part of this code might as well work for me, but I'm so new to renpy I might be wrong. wthout a doubt my coding is, since it doesn't work anyway.
Let me first tell you how my money variable works, it's pretty basic:
in scripts.rpy:
in screens.rpy
Now. What I tried to do was adding the variables:
to the script file because, for the displaying sake, I want the total amount of money to be as readable as possibile as it grows bigger and I don't want ridicolously huge amounts of money spanning from one side of my screen to the other.
So what I tried to do was using something like this:
but I can't trigger them through something like:
..."Then put thousand at the end of the amount" or "Then put millions at the end of the amount" , accordingly.
What should I do?
Thanks!
I've found this topic while trying to tweak my money displayable.
I think that part of this code might as well work for me, but I'm so new to renpy I might be wrong. wthout a doubt my coding is, since it doesn't work anyway.
Let me first tell you how my money variable works, it's pretty basic:
in scripts.rpy:
Code: Select all
init:
$ money = 99999
label start:
show screen money
Code: Select all
screen money:
imagebutton: # MONEY.
xpos 1230
ypos 39
focus_mask None
xanchor "center"
yanchor "center"
idle "icons/money.png"
hbox:
spacing 10 xpos 1150 ypos 25
text "{color=#FFFFFF}{size=-3} $ [money]{/size}{/color}"
Code: Select all
$ thousands= 'K'
$ millions= 'M'
So what I tried to do was using something like this:
Code: Select all
('%s%02d' % (money, thousands)
('%s%02d' % (money, millions)
Code: Select all
if (money > 99999)
if (money > 999999)
..."Then put thousand at the end of the amount" or "Then put millions at the end of the amount" , accordingly.
What should I do?
Thanks!
Re: Money??? please give advice
You already created a topic for that.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Majestic-12 [Bot]