Next question

Chatterbox

Active Member
Game Developer
May 28, 2018
560
3,544
I haven't been able to find an answer to this one no matter where I search.

I'm trying to give money to the MC in my game. I'm using the variable

$ current_money = 0

and later I add money. However ren'py won't display anything above 100 with any variable.

I assume there is a max variable setting coded in somewhere, and I haven't been able to find it. Does anyone know how to remove this limit? I know it's gotta be there somewhere as other games have money systems.

Thanks,
Chatterbox
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
No, Ren'py doesn't have any kind of limit on values that go into variables. It must be something else. How are you "displaying" the variable?
 

Chatterbox

Active Member
Game Developer
May 28, 2018
560
3,544
I have in a screen that I created.

Code:
screen points_hud() tag pointshud:

    modal False

    imagebutton:
        idle "points_hud" hover "points_hud_hover" xalign 0.975 yalign 0.5 focus_mask True action ShowMenu("stats_lexi")
    text "[love_stats_lexi]" xalign 0.935 yalign 0.48 size 40 color "#000000"
    text "[lust_stats_lexi]" xalign 0.935 yalign 0.6 size 40 color "ffffff"
    text "[current_money]" xalign 0.96 yalign 0.75 size 40 color "ffdf00"
 

Chatterbox

Active Member
Game Developer
May 28, 2018
560
3,544
Whats happening is that I can give the MC 1000 dollars, or any amount more than 100, and within two clicks the amount drops to 100. This happens no matter what.
 

lobotomist

Active Member
Sep 4, 2017
907
879
This seems like code for your hud, i dont think the problem is there, can you show the code for the money? Both the interaction and the place the variable is declared
 

Chatterbox

Active Member
Game Developer
May 28, 2018
560
3,544
Yes, it is a hud in the game. The variable is first placed at the top of the script file as:

Code:
$ current_money = 0
When I want to change the variable I use:

Code:
$ current_money = change_stat(current_money,1000)

or

$ current_money = =+1000
Either of those should do the job. I can add whatever I want, be it 1000, 999, 253. No matter what, it drops back down to 100 when displayed. I don't know if it's actually tracking the variable correctly or if it's just parsing down to 100 on the display.
 

lobotomist

Active Member
Sep 4, 2017
907
879
Just to be clear you're initializing the variable before the start label??? One thing i would suggest is printing the value of current_money as dialogue to make sure if it is a problem with the variable.

You could write also an if statement that compares the current money with a previos money var everytime you change money and if they are the same print an error dialogue then equalize the variables after each comparison. If none of this is wrong your hud might be too small to show the value
 

Chatterbox

Active Member
Game Developer
May 28, 2018
560
3,544
@lobotomist That didn't work, but I looked at the code to another game that uses a money system, and figured out how they did it. Apparently if you just use a common variable there is a limit of 100. This is what worked:

Code:
    vbox xalign 0.07yalign 0.5:
        text _("{color=#ffdf00}$ {/color}" + str(Money)):
            xalign 1.0
            size 40
Thanks for the help.

Chatterbox
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
For future reference, the easiest way to figure out if it's a problem with your variable or a problem with the display is to use the console (Shift-O). From there you can look at any of your variables just by typing in its name.

One significant difference between your last block of screen code and your current block of screen code is your "xalign" value - it's possible that in the original version, the last zero in "1000" was actually positioned off the screen, since with an xalign value of 0.96, you weren't aligning with exactly the right-hand edge of your text.

When doing things like this, I don't usually use "align", since it sets two values simultaneously. Instead I use "anchor" and "pos." If you had done
Code:
xanchor 1.0 xpos 0.96
This would have said "put the right edge (xanchor 1.0) of my text 96% of the way (xpos 0.96) across the screen.
Code:
xalign 0.96
is equivalent to
Code:
xanchor 0.96 xpos 0.96
which means "put the spot 96% of the way across my text, 96% of the way across the screen. This means that 4% of your text is going to be to the right of 96% of the way across your screen. Depending on your font size, that could mean that part of your text is off-screen.

Thus, basically, "anchor" works best with values of 0.0 (left/top edge), 1.0 (right/bottom edge) or 0.5 (center). Anything else starts to get tricky.
 
  • Like
Reactions: Chatterbox