Ren'Py Calling a Label for a Gallery

SteelyDan14

Formerly Known as GeekBone
Modder
Donor
Jan 13, 2018
1,211
4,921
I have a scene gallery that is working great, but the game I am creating it for has a crap ton of variables. I solved that problem but there is a scene I am trying to replay that requires that another label has already been viewed. I have search all over and have not been able to find a solution that works.

I have tried calling the label, but it does not seem to work. I am assuming Ren'py stores data in the user profile that flags if you have viewed a scene, but I don't know how to programmatically mark a label as having been viewed.

Thanks!
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
if renpy.seen_label("label_name"): might solve you problem.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
There's also which is set to to True once an image has been shown.

Just be aware, that like , this is persistent data. That is, once it is set, it's effectively set forever. If you restart the game or rollback before that specific part of the game and then play forward a different route, it's still going to be True.

For that reason, it's good for galleries and achievements - but not for making decisions about the state of the current play-through.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,280
I have tried calling the label, but it does not seem to work.
What do you mean by "it does not seem to work" ? And in fact, what are you trying to achieve by calling the label ?

You say that this label have to have been seen, but is it for the gallery entry to be marked as "seen", or during the replay of the event from the gallery ?
Then how are you doing the call ? And, if it have to be called during the replay, what is this label supposed to do ?

Without knowing all this, it's difficult to effectively answer your question. The problem can be the lack of return at the end of the called label, the way you try to call it, or by example in the design of your replay part. As well as it can be what was already answered to, "how know if the label have been seen".

This being said, take a look at the flag. It's how you're supposed to make the behavior of a part of your code differ depending at what moment the player see it (during the game, or during a replay of the scene). And more globally the whole part of the documentation regarding the .


Just be aware, that like , this is persistent data. That is, once it is set, it's effectively set forever. If you restart the game or rollback before that specific part of the game and then play forward a different route, it's still going to be True.
The same being true also for renpy.seen_image().
 

SteelyDan14

Formerly Known as GeekBone
Modder
Donor
Jan 13, 2018
1,211
4,921
Thanks everyone.... based on your suggestions, I got it working but I still have a couple of questions as I feel like there is a cleaner way to do this. Here is the code. For example, I had to change the Exhibitionist value under MCKink to 6 to get a replay to fire... is that the best way to make that happen?

These are part of the main script that I have to declare.

Python:
init python:

    # These general declarations are needed in order to move through the gallery scenes
    # They come from variables.rpy and the various chapters

    # Myriam relations.
    MClove = {
        "Anthony" : 0,
        "Cassius" : 0,
        "Dumdum" : 0,
        "Evelyn" : 0,
        "Katherine" : 0,
        "Liam" : 0,
        "Marc" : 0,
        "Max" : 0,
        "William" : 0,
        "Aiden" : 0,
        "Cleavon" : 0,
        "Danny" : 0,
        "Mike" : 0,
        "Todd" : 0
        }

    # Myriam kinks.
    MCkink = {
        "Anal" : 0,
        "Bestiality" : 0,
        "Big Dick" : 0,
        "Creampie" : 0,
        "Cum" : 0,
        "Deepthroat" : 0,
        "Exhibitionist" : 6,
        "Golden" : 0,
        "Group" : 0,
        "Incest" : 0,
        "Interracial" : 0,
        "Oral" : 0,
        "Pain" : 0,
        "Rough" : 0,
        "Sapphic" : 0,
        "Vanilla" : 0
        }

    # Myriam traits.
    MCtrait = {
        "Cheat" : 0,
        "Curiosity" : 0,
        "Dirtiness" : 0,
        "Dominance" : 0,
        "Happiness" : 0,
        "Loyalty" : 0,
        "Lust" : 0,
        "Risky" : 0,
        "Sadness" : 0,
        "Submissiveness" : 0,
        "Trust" : 0,
        "Willpower" : 0
        }

    discoveries = {
        "Characters" : [],
        "Kinks" : [],
        "Traits" : []
        }
Here is the main gallery code.

Python:
### SCENE GALLERY! ##########################################
screen scenegallery():
    tag menu

    use exgame_menu(scroll="viewport"):
        grid 3 3:
            style_prefix "gslot"
            xalign 5.0
            yalign 5.0
            spacing gui.slot_spacing

            ## scene 1
            if renpy.seen_label ("ch0_intro_redneckmotel"):
                imagebutton:
                    idle "images/thumbnails/scene1.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_intro_redneckmotel")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 2
            if renpy.seen_label ("ch0_going_for_a_shower"):
                imagebutton:
                    idle "images/thumbnails/scene2.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_going_for_a_shower")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 3
            if renpy.seen_label ("ch0_return_redneck_motel_room"):
                imagebutton:
                    idle "images/thumbnails/scene3.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_return_redneck_motel_room")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 4
            if renpy.seen_label ("ch0_newhome_hot_tub_swimsuit_on"):
                imagebutton:
                    idle "images/thumbnails/scene4.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_newhome_hot_tub_swimsuit_on")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 5
            if renpy.seen_label ("ch0_newhome_hot_tub_swimsuit_off"):
                imagebutton:
                    idle "images/thumbnails/scene5.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_newhome_hot_tub_swimsuit_off")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 6
            if renpy.seen_label ("ch0_newhome_fucking_inside"):
                imagebutton:
                    idle "images/thumbnails/scene6.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch0_newhome_fucking_inside")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 7
            if renpy.seen_label ("ch1_nightmare"):
                imagebutton:
                    idle "images/thumbnails/scene7.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch1_nightmare")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 8
            if renpy.seen_label ("ch1_anewday_waking_anthony"):
                imagebutton:
                    idle "images/thumbnails/scene8.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch1_anewday_waking_anthony")
            else:
                add "images/thumbnails/thumbnail_locked.png"

            ## scene 9
            if renpy.seen_label ("ch1_the_street_urchin"):
                imagebutton:
                    idle "images/thumbnails/scene9.png"
                    hover "images/thumbnails/dynamic_hover.png"
                    action Replay("ch1_the_street_urchin")
            else:
                add "images/thumbnails/thumbnail_locked.png"
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,280
For example, I had to change the Exhibitionist value under MCKink to 6 to get a replay to fire...
I gave the start of the answer in my previous comment, you do this with the help of .
Python:
label ch0_going_for_a_shower:
    if _in_replay:
        $ renpy.dynamic( "exhibitionist" )
        exhibitionist = MCKink["Exhibitionist"]
        MCKink["Exhibitionist"] = 5

#    [the effective code of the label]

    if _in_replay:
        MCKink["Exhibitionist"] = exhibitionist
        $ renpy.end_replay()

#    [whatever "return" or "jump" you have at the end of the label]

Python:
init python:
[...]
    MClove = {
        "Anthony" : 0,
[...]
    MCkink = {
        "Anal" : 0,
[...]
    MCtrait = {
        "Cheat" : 0,
[...]
    discoveries = {
        "Characters" : [],
Hmm... All those dictionaries declared in an init block.
Have your game already had a public release ? And if yes, haven't your players complained that the game seem to act strangely, as if it forgot all progress they made each time they close the game ?

I'm asking that, because, well, dictionaries declared in an init block will not be saved...
 
  • Like
Reactions: SteelyDan14

SteelyDan14

Formerly Known as GeekBone
Modder
Donor
Jan 13, 2018
1,211
4,921
I gave the start of the answer in my previous comment, you do this with the help of .
Python:
label ch0_going_for_a_shower:
    if _in_replay:
        $ renpy.dynamic( "exhibitionist" )
        exhibitionist = MCKink["Exhibitionist"]
        MCKink["Exhibitionist"] = 5

#    [the effective code of the label]

    if _in_replay:
        MCKink["Exhibitionist"] = exhibitionist
        $ renpy.end_replay()

#    [whatever "return" or "jump" you have at the end of the label]



Hmm... All those dictionaries declared in an init block.
Have your game already had a public release ? And if yes, haven't your players complained that the game seem to act strangely, as if it forgot all progress they made each time they close the game ?

I'm asking that, because, well, dictionaries declared in an init block will not be saved...
I was worried about that... I am making a gallery for someone else's game and when I did this, I was concerned it would cause problems for the game. These are declared in another file called variables.rpy and then as the game is run, these number change.
 

SteelyDan14

Formerly Known as GeekBone
Modder
Donor
Jan 13, 2018
1,211
4,921
Python:
Python:
label ch0_going_for_a_shower:
if _in_replay:
$ renpy.dynamic( "exhibitionist" )
exhibitionist = MCKink["Exhibitionist"]
MCKink["Exhibitionist"] = 5

#    [the effective code of the label]

if _in_replay:
MCKink["Exhibitionist"] = exhibitionist
$ renpy.end_replay()

# [whatever "return" or "jump" you have at the end of the label]
Thanks for this! This is what I was looking for. I want to move all of those declarations out of the init block and I think I can use this code to do just that.

Thanks again!
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
I was worried about that... I am making a gallery for someone else's game and when I did this, I was concerned it would cause problems for the game. These are declared in another file called variables.rpy and then as the game is run, these number change.

Where they are declared doesn't matter to RenPy. There are some specific exceptions to that rule, but for the most part - the filename of the script doesn't matter.

The way it behaves is that during game startup, RenPy scans for specific commands and processes them immediately. Those commands include init:, init python:, define, default, image and some others I can't recall right now.

Whether they are in script.rpy, variables.rpy or gallery.rpy doesn't matter to RenPy.
Likewise a default line can be at the top of the code, right in the middle somewhere or right at the end. Though convention (and sanity) say to put them at or near the top of the code.

Since you are declaring variables, would you not be better using define or default. Variables declared with define are not stored in save files, whereas variables declared with default are.

The primary difference is that variables declared with define are not expected to change while the game is running (what would be a CONST in other languages), whereas default is for anything that will be changed while the game is being played (hence the need to save them in the save file).

Given the context, I'm assuming default.

So...

Python:
# These general declarations are needed in order to move through the gallery scenes
# They come from variables.rpy and the various chapters

# Myriam relations.
default MClove = {
            "Anthony" : 0,
            "Cassius" : 0,
            "Dumdum" : 0,
            "Evelyn" : 0,
            "Katherine" : 0,
            "Liam" : 0,
            "Marc" : 0,
            "Max" : 0,
            "William" : 0,
            "Aiden" : 0,
            "Cleavon" : 0,
            "Danny" : 0,
            "Mike" : 0,
            "Todd" : 0
        }

# Myriam kinks.
default MCkink = {
            "Anal" : 0,
            "Bestiality" : 0,
            "Big Dick" : 0,
            "Creampie" : 0,
            "Cum" : 0,
            "Deepthroat" : 0,
            "Exhibitionist" : 6,
            "Golden" : 0,
            "Group" : 0,
            "Incest" : 0,
            "Interracial" : 0,
            "Oral" : 0,
            "Pain" : 0,
            "Rough" : 0,
            "Sapphic" : 0,
            "Vanilla" : 0
        }

# Myriam traits.
default MCtrait = {
            "Cheat" : 0,
            "Curiosity" : 0,
            "Dirtiness" : 0,
            "Dominance" : 0,
            "Happiness" : 0,
            "Loyalty" : 0,
            "Lust" : 0,
            "Risky" : 0,
            "Sadness" : 0,
            "Submissiveness" : 0,
            "Trust" : 0,
            "Willpower" : 0
        }

default discoveries = {
            "Characters" : [],
            "Kinks" : [],
            "Traits" : []
        }

As a side note...

Because there might be multiple init: or init python: lines in multiple files, RenPy/python allows them to be numbered (if you don't use a number, it defaults to zero). The numbers determine the order they are run from lowest to highest. So RenPy, for example, would run init -300:, then init -1:, then init:, then init 1: then init 998:. Same for init python:.
 
Last edited:
  • Like
Reactions: SteelyDan14

SteelyDan14

Formerly Known as GeekBone
Modder
Donor
Jan 13, 2018
1,211
4,921
Where they are declared doesn't matter to RenPy. There are some specific exceptions to that rule, but for the most part - the filename of the script doesn't matter.

The way it behaves is that during game startup, RenPy scans for specific commands and processes them immediately. Those commands include init:, init python:, define, default, image and some others I can't recall right now.

Whether they are in script.rpy, variables.rpy or gallery.rpy doesn't matter to RenPy.
Likewise a default line can be at the top of the code, right in the middle somewhere or right at the end. Though convention (and sanity) say to put them at or near the top of the code.

Since you are declaring variables, would you not be better using define or default. Variables declared with define are not stored in save files, whereas variables declared with default are.

Given the context, I'm assuming default.

So...

Python:
# These general declarations are needed in order to move through the gallery scenes
# They come from variables.rpy and the various chapters

# Myriam relations.
default MClove = {
            "Anthony" : 0,
            "Cassius" : 0,
            "Dumdum" : 0,
            "Evelyn" : 0,
            "Katherine" : 0,
            "Liam" : 0,
            "Marc" : 0,
            "Max" : 0,
            "William" : 0,
            "Aiden" : 0,
            "Cleavon" : 0,
            "Danny" : 0,
            "Mike" : 0,
            "Todd" : 0
        }

# Myriam kinks.
default MCkink = {
            "Anal" : 0,
            "Bestiality" : 0,
            "Big Dick" : 0,
            "Creampie" : 0,
            "Cum" : 0,
            "Deepthroat" : 0,
            "Exhibitionist" : 6,
            "Golden" : 0,
            "Group" : 0,
            "Incest" : 0,
            "Interracial" : 0,
            "Oral" : 0,
            "Pain" : 0,
            "Rough" : 0,
            "Sapphic" : 0,
            "Vanilla" : 0
        }

# Myriam traits.
default MCtrait = {
            "Cheat" : 0,
            "Curiosity" : 0,
            "Dirtiness" : 0,
            "Dominance" : 0,
            "Happiness" : 0,
            "Loyalty" : 0,
            "Lust" : 0,
            "Risky" : 0,
            "Sadness" : 0,
            "Submissiveness" : 0,
            "Trust" : 0,
            "Willpower" : 0
        }

default discoveries = {
            "Characters" : [],
            "Kinks" : [],
            "Traits" : []
        }

As a side note...

Because there might be multiple init: or init python: lines in multiple files, RenPy/python allows them to be numbered (if you don't use a number, it defaults to zero). The numbers determine the order they are run from lowest to highest. So RenPy, for example, would run init -300:, then init -1:, then init:, then init 1: then init 998:. Same for init python:.
Love this! Thanks for the help.

I have taken several classes in Python but not a lot of actual coding. Plus Ren'py adds a new wrinkle. Regardless, all of you are helping me connect the dots and I appreciate it.