[Solved] Jumping to label from gallery g.button?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
OldGoateye
Newbie
Posts: 14
Joined: Fri Oct 09, 2015 4:31 am
Contact:

[Solved] Jumping to label from gallery g.button?

#1 Post by OldGoateye » Sun Oct 24, 2021 11:29 pm

So, I've got a nice gallery squared away. It's main-menu accessible only, I can call up images if I like; but I want to use the thumbnails as buttons that jump to labels in the story. Think of it like a chapter selection mode, sort of.

Code: Select all

 g.button("1") # 1st chapter
 g.condition("persistent.1st_replay")
Here's the button, and here's the code that makes it. Many thanks to Zeil for a superlative and easy to follow tutorial that plays nice with legacy projects.

I've tried every combination of action statement (start, jump, etc) I can think of, both in the button definition and make_button zone.

Right now I'm pretty close to tearing my hair out; I'm so close, here!
I'd be incredibly grateful for even a hint of help. I know that it's do-able, and I'm probably missing something obvious.

Also, here's the ideal output; player replays games, gets extra scenes and chapters. When unlocked, an image thumbnail hints at what the scene might have.
On clicking, some text pops up. "Replay chapter one from a different perspective?" Yes/no choice, no lets you keep browsing the gallery, yes jumps to the label and begins the scene (which ends with a return to the gallery, rather than a return to the main menu or exit).
Last edited by OldGoateye on Tue Oct 26, 2021 8:16 am, edited 1 time in total.

OldGoateye
Newbie
Posts: 14
Joined: Fri Oct 09, 2015 4:31 am
Contact:

Re: Jumping to label from gallery g.button?

#2 Post by OldGoateye » Mon Oct 25, 2021 10:31 pm

I wanted to update this, even if nobody will help. Maybe this'll help someone else going forward.

Turning my (nice, workable, lockable) g.buttons into imagebuttons...

Code: Select all

screen gallery:
    tag menu
    add "gui/sunshine.png"
    hbox:
        yalign 0.5
        xalign 0.5
        grid 2 2:
            xspacing 25
            yspacing 70
            button:
                image "gui/chapter_one.png" # formerly these were add g.make_button ala Zeil's code because that was simpler and thus better.
                action Jump("chp1")


... Will in fact jump to chapter one. Cool, awesome!

But:
  • There's no way to lock the button that I can see. if? if/else for every button seems excessive, though, compared the relative simplicity of using persistents.
  • It appears to be impossible to add a text call describing the link, e.g. "This will replay chapter one. {w}Proceed?" followed by menu yes/no.
  • It is impossible to use menus, right click, or any other commands while viewing chapter one. This is a dealbreaker.
  • It seems impossible to return to the gallery from the script. return("gallery") just starts the game from the beginning. I'm using an if on the screens rpy to ensure that the gallery can't be accessed out of the main menu. Is that the reason why?

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Jumping to label from gallery g.button?

#3 Post by Ocelot » Tue Oct 26, 2021 5:42 am

The gallery is easy and straightforward to use, because it takes normal button and removes everything not suited for displaying images. You do not need to confugure dozens propertier, do not need to make hundred choices on what your button will do and how it would be created: everything is already decided for you. Gallery is a powerful and simple tool because it does not allow you to do anything else. Trying to make it do something else is fighting against its whole purpose.

You will need to make something similar manually.
OldGoateye wrote:
Mon Oct 25, 2021 10:31 pm
There's no way to lock the button that I can see. if? if/else for every button seems excessive, though, compared the relative simplicity of using persistents.
https://www.renpy.org/doc/html/screens.html#imagebutton
insensitive property for Locked image
sensitive property for unlock condition
And gallery code uses a lot of conditionals inside. You just don't see them (and cannot change them), because author hid them from you.
OldGoateye wrote:
Mon Oct 25, 2021 10:31 pm
It appears to be impossible to add a text call describing the link, e.g. "This will replay chapter one. {w}Proceed?" followed by menu yes/no.
Use Confirm action.
OldGoateye wrote:
Mon Oct 25, 2021 10:31 pm
It is impossible to use menus, right click, or any other commands while viewing chapter one. This is a dealbreaker.
Did you use Jump action from the main menu? Then you are not technically in the game, you are still in the main menu. Menu that shows you images and dialogue, but still menu. You cannot exit to main menu from main menu.
To start the game you need to use Start action.
< < insert Rick Cook quote here > >

OldGoateye
Newbie
Posts: 14
Joined: Fri Oct 09, 2015 4:31 am
Contact:

Re: Jumping to label from gallery g.button?

#4 Post by OldGoateye » Tue Oct 26, 2021 8:14 am

I am going to quote this because the rest of your answer was incredibly helpful and informative 'as is.'
Ocelot wrote:
Tue Oct 26, 2021 5:42 am
You will need to make something similar manually.
Can any room basically be a carbon copy of the gallery, then? I could create a room 'memoryroom' and basically have it do the same function...
If that's what the solution is, I feel like a titanic idiot. I knew it would prove to be something like that but I am still grateful.

Thanks for help; going to mark this as solved for now.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]