Ren'Py [SOLVED]Secret gallery issue

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
(in-long) Hey been stuck with this pesky secret gallery for days now and my ape brain cannot figure out how could i solve it:D I've tried with soo many forum codes but I couldn't really figure out. Also i have no idea that why I've put the code like this as i have no programming background at all. I just crafted things together which I've found online:)

(in-short) Whenever the button is pressed you should unlock an image but if i put the show/hide into the button action its doesnt work. The way my code works at the moment that it gives you the picture even if you didnt click the button.


The code:

secret_gallery.rpy
image special1 = "blabla.png"

init python:
gallery = Gallery()
gallery.button("special1")
gallery.unlock_image("special1")

gallery.locked_button = ("blablalocked.png")

screen secret_gallery:
tag menu
hbox:
xalign 0.5
yalign 0.1
spacing 30

add gallery.make_button(name="special1" ,unlocked="blabla.png")

script.rpy
default secret_button1 = False
screen secret_button():
add "blabla.png"
if not secret_button1:
imagebutton:
focus_mask True
idle "blabla_idle.png"
hover "blabla_hover.png"
action [ToggleScreen("secret_button"), Return()]
(later in code)

$ renpy.display_notify("Special render available")
show screen secret_button
show special1
hide special1
mc "blablablaalala"
hide screen secret_button
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,131
14,813
[...] but if i put the show/hide into the button action its doesnt work.
Well, since the and screen actions are to display screens, it's not surprising that it don't works when you ask them to deal with an image.

You should probably rely on to unlock the gallery, instead of the image being seen. Then, a simple SetField( persistent, "whatever", True ) as action for the imagebutton would unlock it. Assumed that you defined your gallery with something like:
Python:
gallery.button("whatever")
gallery.condition("persistent.whatever")
gallery.image("whatever.jpg")
 
  • Like
Reactions: 3DeadAngel

MissFortune

I Was Once, Possibly, Maybe, Perhaps… A Harem King
Respected User
Game Developer
Aug 17, 2019
4,572
7,556
Wouldn't it just be easier to make a screen with said render in it?

The notification I'd use in this case:
Python:
screen specialrender_notif():
    frame:
        ATL Transform (or just delete line)
        add "notif" #image/video/etc
        timer 4.0 action Hide("specrendnotif", transition=dissolve)
The button for that special render:
Python:
screen specialrender1_button():
    style_prefix "blahblah"
    zorder 100 #likely not needed, contextual for me.
    frame:
        has vbox:
            xalign 0.02 #if needed
            yalign 0.02 #if needed
            imagebutton:
                idle "renderbutton_idle.png"
                hover "renderbutton_hover.png"
                hovered Play("sound", "music/hover.wav") #if you have sound effects on hover
                action Show("specialrender1")
You can just use a typical 'imagebutton auto' above here, as well.

the screen for said special render:
Python:
screen specialrender1:
    add "image path and/or name of defined image"

    button:
        xsize 1920
        ysize 1080
        action Hide('specialrender1')
As for the 'button' bit on the last bit of the code there. What that's doing is basically turning the entire screen into an exit button for the render. It can be easily replaced with an exit imagebutton, if needed/wanted, but it saves some work which is why I used it.

I don't use special render galleries or anything, so this code is pulled specifically from my own gallery code, but it should work similarly. Here's how that code works in my gallery:

View attachment 2023-10-21 02-10-17.mp4
















So, basically, notification for new render > button for new render > special render > exit special render.

Python:
$ specialrender1_button = True

if specialrender1_button = True:
    show screen specialrender_notif
    show screen specialrender1_button
    show specialrender1 #The button in the above code will exit here with a click, making the hide below in your code unneeded.
    mc "blablablaalala"
    hide screen specialrender1_button
else:
    pass #or whatever else you want to put here.
mc "blahhh, blahh, BLAHH!"
And then you could just add it to the gallery as normal.
 
  • Like
Reactions: 3DeadAngel

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
Well, since the and screen actions are to display screens, it's not surprising that it don't works when you ask them to deal with an image.

You should probably rely on to unlock the gallery, instead of the image being seen. Then, a simple SetField( persistent, "whatever", True ) as action for the imagebutton would unlock it. Assumed that you defined your gallery with something like:
Python:
gallery.button("whatever")
gallery.condition("persistent.whatever")
gallery.image("whatever.jpg")

Oh wow that did the magic thanks:)
 

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
Wouldn't it just be easier to make a screen with said render in it?

The notification I'd use in this case:
Python:
screen specialrender_notif():
    frame:
        ATL Transform (or just delete line)
        add "notif" #image/video/etc
        timer 4.0 action Hide("specrendnotif", transition=dissolve)
The button for that special render:
Python:
screen specialrender1_button():
    style_prefix "blahblah"
    zorder 100 #likely not needed, contextual for me.
    frame:
        has vbox:
            xalign 0.02 #if needed
            yalign 0.02 #if needed
            imagebutton:
                idle "renderbutton_idle.png"
                hover "renderbutton_hover.png"
                hovered Play("sound", "music/hover.wav") #if you have sound effects on hover
                action Show("specialrender1")
You can just use a typical 'imagebutton auto' above here, as well.

the screen for said special render:
Python:
screen specialrender1:
    add "image path and/or name of defined image"

    button:
        xsize 1920
        ysize 1080
        action Hide('specialrender1')
As for the 'button' bit on the last bit of the code there. What that's doing is basically turning the entire screen into an exit button for the render. It can be easily replaced with an exit imagebutton, if needed/wanted, but it saves some work which is why I used it.

I don't use special render galleries or anything, so this code is pulled specifically from my own gallery code, but it should work similarly. Here's how that code works in my gallery:

View attachment 3022340
















So, basically, notification for new render > button for new render > special render > exit special render.

Python:
$ specialrender1_button = True

if specialrender1_button = True:
    show screen specialrender_notif
    show screen specialrender1_button
    show specialrender1 #The button in the above code will exit here with a click, making the hide below in your code unneeded.
    mc "blablablaalala"
    hide screen specialrender1_button
else:
    pass #or whatever else you want to put here.
mc "blahhh, blahh, BLAHH!"
And then you could just add it to the gallery as normal.

Thats a really long reply with amazing explaning, thank you for it! Your codes looks super clean as well so i might as well switch to it:D