Back again... Displaying Points Renpy

TheTypist

Active Member
Donor
Game Developer
Sep 7, 2017
694
4,185
I'll make this quick. Plenty of games show you in the top corner with a cute heart or broken heart how many lust or love points we have with each character.
I already have the points system enabled, and it works perfectly as far as "If 6 lust points. then this route, else, then THIS route."
So what code will allow me to show the player how many points they have as they go?
If you also know the code for where I may put an image such as said heart or broken heart, what is that code.

Thank you
 

bas

retired
Donor
Respected User
Former Staff
May 6, 2017
3,988
30,555
I'll make this quick. Plenty of games show you in the top corner with a cute heart or broken heart how many lust or love points we have with each character.
I already have the points system enabled, and it works perfectly as far as "If 6 lust points. then this route, else, then THIS route."
So what code will allow me to show the player how many points they have as they go?
If you also know the code for where I may put an image such as said heart or broken heart, what is that code.

Thank you
Here's how I learned: Take a game that you like they way they're doing it, unpack the rpa files and decompile the rpyc files with a tool called unren here:

The file you want to look at is screens.rpy. It has all that stuff and then you can show or hide it using renpy screen code from your script.rpy "show screen points" if you name the screen "points".
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
I'll make this quick. Plenty of games show you in the top corner with a cute heart or broken heart how many lust or love points we have with each character.
I already have the points system enabled, and it works perfectly as far as "If 6 lust points. then this route, else, then THIS route."
So what code will allow me to show the player how many points they have as they go?
If you also know the code for where I may put an image such as said heart or broken heart, what is that code.

Thank you
@bossapplesauce is correct that what you need to do is build a screen, and then "show" it. Note that the screen doesn't have to have its code in "screens.rpy," however - you can put any Renpy code you want in any .rpy file you want, and Renpy will merge them all together. So there's nothing magic about the screen names.

Screens are defined using Ren'py's "screen language" (duh!) The simplest case for you would be:

Code:
screen points_screen():
    text "[player_points]" align(0.0, 0.0)
This creates a screen named "points_screen" which has a single item - a text element that will display the "player_points" variable, aligned to the left, top corner of the screen. You'll probably want to deal with color, slightly better position, font size, etc., all of which can be done with modifiers to the text element.

Having created what you want, as @bossapplesauce mentioned, you just execute a "show screen points_screen" command as part of your script. This will cause your screen to be displayed effectively as an overlay on the rest of the game. If you need to hide the points, you can then do "hide screen points_screen"

As to adding the heart, that uses the "add" screen element. So maybe your screen would look like:
Code:
screen points_screen():
    text "[player_points]" align(0.0, 0.0)
    add "heart_image" anchor(0.0, 0.0) pos(100,0)
This adds the image "heart_omage" such that it's top left corner is 100 pixels from the left edge of the screen, and its top edge is at the top of the screen. (The idea being to put it to the right of the points text)

You can use conditionals in screens too:
Code:
screen points_screen():
    text "[player_points]" align(0.0, 0.0)
    if player_points < 10:
        add "small_heart_image" anchor(0.0, 0.0) pos(100,0)
    else
        add "big_heart_image" anchor(0.0, 0.0) pos(100,0)
Screen language is documented here: This is a reference, not a tutorial (as is true for most Ren'py documentation pages) but will describe the various elements you can use in a screen.

And, yes, reverse-engineering how other games do things is a good way to learn Ren'py's capabilities.
 

Jackboo1

Member
Aug 26, 2017
277
1,387
Also, it's possible making stats with bars by using "bar" with different styles, horizontal or vertical (you can even change the png transparent image for whatever you want... like hearts, penis, pussy etc).

Code:
style h_bar:
    right_bar "empty_bar.png"
    left_bar "hover_bar.png"
    xalign 0.0
    yalign 0.0
    xysize (200,20)

screen charstats:
    modal True
    default x = renpy.get_mouse_pos()[0]
    default y = renpy.get_mouse_pos()[1]
    frame:
        pos (x + 15, y + 20)
        xpadding 20
        ypadding 10
        has vbox
        xsize 350
        ysize 500
        text "CHAR1 SEX POINTS"
        bar:
            style "h_bar"
            range 100
            ypos 10
            value char1_sex #your points variable


This will not show any stats number, only the progress bar, but you can choose to show it if you want, I don't like that tho

Related tutorial

 
  • Like
Reactions: Alvidas and bas

TheTypist

Active Member
Donor
Game Developer
Sep 7, 2017
694
4,185
Thank you @Rich and @Jackboo1 for your replies. Rich, this is exactly what I was looking for fine sir. I hope other future devs see these threads when seeking the same help. Always appreciate it!
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
Thank you @Rich and @Jackboo1 for your replies. Rich, this is exactly what I was looking for fine sir. I hope other future devs see these threads when seeking the same help. Always appreciate it!
You're completely welcome - that's why these forums are here. :)