Ren'Py Can someone help with with money system?

DanStory

Newbie
Sep 30, 2021
50
66
I'm new in renpy and i already searching in youtube etc, and i still confused how to increase and decrease money if i toake the money from roaming screen
can someone help me ti give the code for money system?
I already create the .png image for the money
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
I'm new in renpy and i already searching in youtube etc, and i still confused how to increase and decrease money if i toake the money from roaming screen
You'll have to be more precise in what you effectively want to do. But basically speaking:
From a label you increase the money with $ money += 10, and decrease it with $ money -= 10. While from a screen, it's respectively SetVariable( "money", money + 10) and SetVariable( "money", money - 10) that you've to put in the chain of your button ; whatever if it's an or a .
 
  • Like
Reactions: DanStory

DanStory

Newbie
Sep 30, 2021
50
66
You'll have to be more precise in what you effectively want to do. But basically speaking:
From a label you increase the money with $ money += 10, and decrease it with $ money -= 10. While from a screen, it's respectively SetVariable( "money", money + 10) and SetVariable( "money", money - 10) that you've to put in the chain of your button ; whatever if it's an or a .
thanks i'll try
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
I'm new in renpy and i already searching in youtube etc, and i still confused how to increase and decrease money if i toake the money from roaming screen
can someone help me ti give the code for money system?


It's a really open ended question, and honestly may mean you don't understand the basics yet.
I'd suggest reading the , followed by .

So... "money" is usually stored as a variable. Variables can be different types. In this case, you probably want an integer variable (which is just any number without any decimal places). For more information on variables, see my post here.
The other common types in RenPy games are boolean (Yes/No, True/False) and string (text).

So let's call the variable mymoney and start it at zero. To create a variable, you want to use a default statement. default statements can go anywhere in the code, but it's standard practice to include them near (or at) the top of your code.

Python:
default mymoney = 0

Next... you want to alter the value of the variable. The very simplest way is to add or subtract another number from the variable. You do this by asking RenPy to run a python command (using $ ). Python has a shorthand way of adding and subtracting... += or -= .

So to add 50 to the variable, then subtract 25... you'd expect to see code like:

Python:
    $ mymoney += 50
    $ mymoney -= 25

Now, you wouldn't do that in isolation. It would usually be dependant upon something else. Either a player choice or based on the value of another variable. The combination and complexity of how these variables are changed and how that is implemented within a game is just a matter of your experience and logical thinking.

So you might see something like:

Python:
default mymoney = 0
default bought_cell_phone = False

label start:

    scene black with fade

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "Today, I have $[mymoney]."

    "*** THE END ***"
    return

In this example, there's no way for the boolean variable bought_cell_phone to ever be True. But it's just an example and so don't worry about it.

I already create the .png image for the money

Yeah. Well. I'm really not sure what you are getting at here.
Your 3 images seem to have the dollar sign slightly further to the left each time. So maybe 2 = 2 digit numbers, 3=3 digit numbers and 4=4 digit numbers?

Except why would anyone do it like that?

In dialogue, as I've included above, you need only put the name of a variable within square brackets to include the value in text dialogue spoken by a character or shown in a similar way.

Today, I have $[mymoney]." would show as Today, I have $50.", for example.

If you want things to be green (as the images are), you need only add tags (or maybe even tags).

"Today, I have {color=#33CC00}$[mymoney]{/color}."


However, this "feels" like something you want to show on screen. Perhaps permanently on screen on some sort of gui toolbar. And for that, you are going to need .

Now, screen language is relatively straight forward - but not easy to get to grips with. If you are already struggling with variables, you are going to struggle with screen language even more.

But let's answer your question and expand our example to include a screen which shows the amount of money the player has in the top right corner of the screen all the time.

Python:
default mymoney = 0
default bought_cell_phone = False

screen money_box():
    fixed:
        text "${}".format(mymoney):
            xalign 1.0 yalign 0.0
            text_align 1.0
            color "#33CC00"

label start:

    scene black with fade

    show screen money_box()

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "*** THE END ***"
    return

Obviously, there's a lot going on there and lots of new stuff and concepts. But you don't need an image of a dollar sign to put a dollar sign in the right place. The rest of it... alignments are a sliding scale of 0.0 (left/top) to 1.0 (right/bottom), with 0.5 being the center. color should be self explanatory. The text "${}".format(mymoney): is required because screen code has to use python formatting instead of text tags, with {} being replaced by the value of .format(mymoney), which is .
 
Last edited:
  • Like
Reactions: DanStory

DanStory

Newbie
Sep 30, 2021
50
66
It's a really open ended question, and honestly may mean you don't understand the basics yet.
I'd suggest reading the , followed by .

So... "money" is usually stored as a variable. Variables can be different types. In this case, you probably want an integer variable (which is just any number without any decimal places). For more information on variables, see my post here.
The other common types in RenPy games are boolean (Yes/No, True/False) and string (text).

So let's call the variable mymoney and start it at zero. To create a variable, you want to use a default statement. default statements can go anywhere in the code, but it's standard practice to include them near (or at) the top of your code.

Python:
default mymoney = 0

Next... you want to alter the value of the variable. The very simplest way is to add or subtract another number from the variable. You do this by asking RenPy to run a python command (using $ ). Python has a shorthand way of adding and subtracting... += or -= .

So to add 50 to the variable, then subtract 25... you'd expect to see code like:

Python:
    $ mymoney += 50
    $ mymoney -= 25

Now, you wouldn't do that in isolation. It would usually be dependant upon something else. Either a player choice or based on the value of another variable. The combination and complexity of how these variables are changed and how that is implemented within a game is just a matter of your experience and logical thinking.

So you might see something like:

Python:
default mymoney = 0
default bought_cell_phone = False

label start:

    scene black with fade

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "Today, I have $[mymoney]."

    "*** THE END ***"
    return

In this example, there's no way for the boolean variable bought_cell_phone to ever be True. But it's just an example and so don't worry about it.




Yeah. Well. I'm really not sure what you are getting at here.
Your 3 images seem to have the dollar sign slightly further to the left each time. So maybe 2 = 2 digit numbers, 3=3 digit numbers and 4=4 digit numbers?

Except why would anyone do it like that?

In dialogue, as I've included above, you need only put the name of a variable within square brackets to include the value in text dialogue spoken by a character or shown in a similar way.

Today, I have $[mymoney]." would show as Today, I have $50.", for example.

If you want things to be green (as the images are), you need only add tags (or maybe even tags).

"Today, I have {color=#33CC00}$[mymoney]{/color}."


However, this "feels" like something you want to show on screen. Perhaps permanently on screen on some sort of gui toolbar. And for that, you are going to need .

Now, screen language is relatively straight forward - but not easy to get to grips with. If you are already struggling with variables, you are going to struggle with screen language even more.

But let's answer your question and expand our example to include a screen which shows the amount of money the player has in the top right corner of the screen all the time.

Python:
default mymoney = 0
default bought_cell_phone = False

screen money_box():
    fixed:
        text "${}".format(mymoney):
            xalign 1.0 yalign 0.0
            text_align 1.0
            color "#33CC00"

label start:

    scene black with fade

    show screen money_box()

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "*** THE END ***"
    return

Obviously, there's a lot going on there and lots of new stuff and concepts. But you don't need an image of a dollar sign to put a dollar sign in the right place. The rest of it... alignments are a sliding scale of 0.0 (left/top) to 1.0 (right/bottom), with 0.5 being the center. color should be self explanatory. The text "${}".format(mymoney): is required because screen code has to use python formatting instead of text tags, with {} being replaced by the value of .format(mymoney), which is .
thank you bro you're so kind... thanks i'll learn that
 

DanStory

Newbie
Sep 30, 2021
50
66
It's a really open ended question, and honestly may mean you don't understand the basics yet.
I'd suggest reading the , followed by .

So... "money" is usually stored as a variable. Variables can be different types. In this case, you probably want an integer variable (which is just any number without any decimal places). For more information on variables, see my post here.
The other common types in RenPy games are boolean (Yes/No, True/False) and string (text).

So let's call the variable mymoney and start it at zero. To create a variable, you want to use a default statement. default statements can go anywhere in the code, but it's standard practice to include them near (or at) the top of your code.

Python:
default mymoney = 0

Next... you want to alter the value of the variable. The very simplest way is to add or subtract another number from the variable. You do this by asking RenPy to run a python command (using $ ). Python has a shorthand way of adding and subtracting... += or -= .

So to add 50 to the variable, then subtract 25... you'd expect to see code like:

Python:
    $ mymoney += 50
    $ mymoney -= 25

Now, you wouldn't do that in isolation. It would usually be dependant upon something else. Either a player choice or based on the value of another variable. The combination and complexity of how these variables are changed and how that is implemented within a game is just a matter of your experience and logical thinking.

So you might see something like:

Python:
default mymoney = 0
default bought_cell_phone = False

label start:

    scene black with fade

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "Today, I have $[mymoney]."

    "*** THE END ***"
    return

In this example, there's no way for the boolean variable bought_cell_phone to ever be True. But it's just an example and so don't worry about it.




Yeah. Well. I'm really not sure what you are getting at here.
Your 3 images seem to have the dollar sign slightly further to the left each time. So maybe 2 = 2 digit numbers, 3=3 digit numbers and 4=4 digit numbers?

Except why would anyone do it like that?

In dialogue, as I've included above, you need only put the name of a variable within square brackets to include the value in text dialogue spoken by a character or shown in a similar way.

Today, I have $[mymoney]." would show as Today, I have $50.", for example.

If you want things to be green (as the images are), you need only add tags (or maybe even tags).

"Today, I have {color=#33CC00}$[mymoney]{/color}."


However, this "feels" like something you want to show on screen. Perhaps permanently on screen on some sort of gui toolbar. And for that, you are going to need .

Now, screen language is relatively straight forward - but not easy to get to grips with. If you are already struggling with variables, you are going to struggle with screen language even more.

But let's answer your question and expand our example to include a screen which shows the amount of money the player has in the top right corner of the screen all the time.

Python:
default mymoney = 0
default bought_cell_phone = False

screen money_box():
    fixed:
        text "${}".format(mymoney):
            xalign 1.0 yalign 0.0
            text_align 1.0
            color "#33CC00"

label start:

    scene black with fade

    show screen money_box()

    menu:
        "Go to work":
            "You went to work and were paid $50."
            $ mymoney += 50

        "Sleep in bed all day":
            "You spend all day in bed."

    if bought_cell_phone == True:
        "Your cell phone bill was paid today. $25."
        $ mymoney -= 25

    "*** THE END ***"
    return

Obviously, there's a lot going on there and lots of new stuff and concepts. But you don't need an image of a dollar sign to put a dollar sign in the right place. The rest of it... alignments are a sliding scale of 0.0 (left/top) to 1.0 (right/bottom), with 0.5 being the center. color should be self explanatory. The text "${}".format(mymoney): is required because screen code has to use python formatting instead of text tags, with {} being replaced by the value of .format(mymoney), which is .
you're so good with renpy dude, can I send you a DM when I need help with coding and stuff?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
you're so good with renpy dude, can I send you a DM when I need help with coding and stuff?
Not to be harsh, or minimize 79flavors knowledge, but honestly what he said is the basis. Therefore if you think he's "so good with renpy" (what he is, but isn't shown this time), you should really start by taking the time to patiently and carefully read the documentation he pointed to.

You'll not go far without this mandatory initial step, this whatever how much help you could get.
Of course, you can start a thread here and ask for help. You would get an answer, perhaps even a working script. But what's important is to understand this answer/script, in order to effectively adapt it to you unique case and, more important, be able to fix the errors that will come from this adaptation.
You aren't alone on your journey, but you are alone face to your game. Therefore the very first step should be to reach independence in regard of the basic tasks. And this can only be achieved through the reading of the documentation and some personal experimentation.
 
  • Like
Reactions: DanStory

DanStory

Newbie
Sep 30, 2021
50
66
Not to be harsh, or minimize 79flavors knowledge, but honestly what he said is the basis. Therefore if you think he's "so good with renpy" (what he is, but isn't shown this time), you should really start by taking the time to patiently and carefully read the documentation he pointed to.

You'll not go far without this mandatory initial step, this whatever how much help you could get.
Of course, you can start a thread here and ask for help. You would get an answer, perhaps even a working script. But what's important is to understand this answer/script, in order to effectively adapt it to you unique case and, more important, be able to fix the errors that will come from this adaptation.
You aren't alone on your journey, but you are alone face to your game. Therefore the very first step should be to reach independence in regard of the basic tasks. And this can only be achieved through the reading of the documentation and some personal experimentation.
Yes and I'm trying to understand this and the basis and try with experiment project before apply to the real project.
I already trying to understand and study from renpy but maybe my english so bad so im little bit confused, that's why i ask here.
but with 79flavors explaination and detail and also give the example for me, i can more understand what i have to do and what i have to try before apply to the real project.
that's why i'm said he so kind and so good.
and thank you for your help too.
renpy is new for me and im really appreciate you and 79flavors help me.
thank you so much dude.
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
[...] can I send you a DM when I need help with coding and stuff?

I'd rather not do 1-to-1 support, if I'm honest. I'm not always available or in the mood to answer.

Public messages mean anyone from the community can reply.

My suggestion is to start smaller. Try a small kinetic novel first (no decisions, no variables). Either write or find a short story and re-recreate it in RenPy for 20-30 minutes of gameplay. It'll teach you the basics and give you a feel for the effort required for creating the images too.
 

DanStory

Newbie
Sep 30, 2021
50
66
I'd rather not do 1-to-1 support, if I'm honest. I'm not always available or in the mood to answer.

Public messages mean anyone from the community can reply.

My suggestion is to start smaller. Try a small kinetic novel first (no decisions, no variables). Either write or find a short story and re-recreate it in RenPy for 20-30 minutes of gameplay. It'll teach you the basics and give you a feel for the effort required for creating the images too.
okay no problem dude thanks for your help

i already started create some progress and use choice and screen for roaming.
and now i'm learning to using money system in renpy from you.
this is the example for the image from my progress, im using daz now.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
Such wonderful, and so perfectly reasoned opinion, backed up be undeniable facts, clearly justify that you necroed a one and half dead thread...
 
Last edited by a moderator: