Ren'Py Gallery Images Don't Unlock

Impious Monk

Active Member
Game Developer
Oct 14, 2021
626
2,808
I am trying to create a gallery of bonus scenes which a player unlocks by completing each of eight parts in the game. Taking baby steps, before I try to add the actual scenes I'm just trying to get simple images to unlock. But I am failing. Here is my code:

Code:
init python:
    gallery = Gallery()

    gallery.button("bonus1")
    gallery.condition("persistent.unlock_1")
    gallery.unlock_image("images/other/1-5.jpg")

    gallery.button("bonus2")
    gallery.condition("persistent.unlock_2")
    gallery.unlock_image("bonus2")

    gallery.button("bonus3")
    gallery.condition("persistent.unlock_3")
    gallery.unlock_image("bonus3")

    gallery.button("bonus4")
    gallery.condition("persistent.unlock_4")
    gallery.unlock_image("bonus4")

    gallery.button("bonus5")
    gallery.condition("persistent.unlock_5")
    gallery.unlock_image("bonus5")

    gallery.button("bonus6")
    gallery.condition("persistent.unlock_6")
    gallery.unlock_image("bonus6")

    gallery.button("bonus7")
    gallery.condition("persistent.unlock_7")
    gallery.unlock_image("bonus7")

    gallery.button("bonus8")
    gallery.condition("persistent.unlock_8")
    gallery.unlock_image("bonus8")

screen gallery:

    tag menu

    hbox:
        xalign 0.5
        yalign 0.5
        spacing 30
        grid 4 2:
            add gallery.make_button(name="bonus1",unlocked="images/s1_1/1-5.jpg", locked="images/other/gallery_lock1.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-6", locked="images/other/gallery_lock2.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-7", locked="images/other/gallery_lock3.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-8", locked="images/other/gallery_lock4.jpg")
            add gallery.make_button(name="bonus1",unlocked="1-9", locked="images/other/gallery_lock5.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-10", locked="images/other/gallery_lock6.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-11", locked="images/other/gallery_lock7.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-12", locked="images/other/gallery_lock8.jpg")
            spacing 15
        textbutton "Return" action Return()
I'm using the bonus1 image as my testing image. I've set the
Code:
 $ persistent.unlock_1 = True
value in the code at the end of Part One of my script and played through it (multiple times). But there is no change in my gallery screen. I'm not sure if the first image is supposed to change automatically to the unlocked image or if I'm supposed to click on it to show the unlocked image. But either way, I still just get the locked image (labeled "Part One" below).

Can anyone help?

gallery.jpg
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,130
3,194
take name= out it's not need

Python:
add gallery.make_button(name="bonus1",unlocked="images/s1_1/1-5.jpg", locked="images/other/gallery_lock1.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-6", locked="images/other/gallery_lock2.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-7", locked="images/other/gallery_lock3.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-8", locked="images/other/gallery_lock4.jpg")
            add gallery.make_button(name="bonus1",unlocked="1-9", locked="images/other/gallery_lock5.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-10", locked="images/other/gallery_lock6.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-11", locked="images/other/gallery_lock7.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-12", locked="images/other/gallery_lock8.jpg")
 

Impious Monk

Active Member
Game Developer
Oct 14, 2021
626
2,808
take name= out it's not need

Python:
add gallery.make_button(name="bonus1",unlocked="images/s1_1/1-5.jpg", locked="images/other/gallery_lock1.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-6", locked="images/other/gallery_lock2.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-7", locked="images/other/gallery_lock3.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-8", locked="images/other/gallery_lock4.jpg")
            add gallery.make_button(name="bonus1",unlocked="1-9", locked="images/other/gallery_lock5.jpg")
            add gallery.make_button(name="bonus2",unlocked="1-10", locked="images/other/gallery_lock6.jpg")
            add gallery.make_button(name="bonus3",unlocked="1-11", locked="images/other/gallery_lock7.jpg")
            add gallery.make_button(name="bonus4",unlocked="1-12", locked="images/other/gallery_lock8.jpg")
Thank you, that does make the code a bit cleaner.

Still looking for a fix to my problem, though.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Ignore me.

I'm so used to people using custom gallery code, I assumed it was a gallery you'd downloaded elsewhere.
My mistake was not noticing that you're using the standard inbuilt provided by RenPy.

Looking a little closer now...

It's difficult to diagnose without all the code.

The first code block shows creation of the new gallery object, based on the Gallery class. But you haven't included the class Gallery code.

Likewise, the second code block shows creation of the onscreen buttons using function make_button(), but that code isn't included either.

The error is likely within the function make_button(), since that will be making the decision about whether to lock or unlock the image to allow it to be interacted with. Probably something to do with how it checks condition when figuring out whether to use the locked or unlocked image for each button (and the related button action()).
 
Last edited:
  • Like
Reactions: Impious Monk

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,210
Code:
init python:
    gallery = Gallery()

    gallery.button("bonus1")
    gallery.condition("persistent.unlock_1")
    gallery.unlock_image("images/other/1-5.jpg")
I'm not to familiar with the gallery feature, but if I'm sufficiently awake, you're giving two conditions to your gallery.
The first one with gallery.condition() (here "persistent.unlock_1" must be True), and one with gallery.unlock_image() (here, "images/other/1-5.jpg" must have been seen).

Can it be that "images/other/1-5.jpg" is the image you want to show when the gallery is unlocked, and not an image unlocking itself ?
In this case, just replacing gallery.unlock_image() by gallery.image() should fix your issue.
 
  • Like
Reactions: Impious Monk

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,130
3,194
here is a different one that I have used and it works better then the one in the renpy documents


there a lot of other members on the renpy forums stated it doesn't work that well
what 79flavors have pointed out that you might be using
I had problems getting the standard inbuilt provided by RenPy to work as well
 
Last edited:
  • Like
Reactions: Impious Monk

Impious Monk

Active Member
Game Developer
Oct 14, 2021
626
2,808
I'm not to familiar with the gallery feature, but if I'm sufficiently awake, you're giving two conditions to your gallery.
The first one with gallery.condition() (here "persistent.unlock_1" must be True), and one with gallery.unlock_image() (here, "images/other/1-5.jpg" must have been seen).

Can it be that "images/other/1-5.jpg" is the image you want to show when the gallery is unlocked, and not an image unlocking itself ?
In this case, just replacing gallery.unlock_image() by gallery.image() should fix your issue.
Thanks! That did the trick.
 

Impious Monk

Active Member
Game Developer
Oct 14, 2021
626
2,808
This forum feels like having my own free tech support unit. :ROFLMAO:

You are all very much appreciated!