Exception in creating a second gallery

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
User avatar
krt_org
Newbie
Posts: 14
Joined: Wed Jul 04, 2018 7:48 pm
Contact:

Exception in creating a second gallery

#1 Post by krt_org »

Hi. I am having an issue with creating a second gallery for my game. I'm using the same code for a different gallery in the project already. The first gallery is for character profiles and runs perfectly fine. This second gallery will display other images. I am unsure if there would be an issue in having two galleries in one project or what. Here's my code:

Code: Select all

init python:

    gl = Gallery()

    gl.button("opn1")
    gl.condition("persistent.ch01")
    gl.image("opinion1.png")
    
    gl.button("opn2")
    gl.condition("persistent.ch02")
    gl.image("opinion2.png")

    gl.button("opn3")
    gl.condition("persistent.ch03")
    gl.image("opinion3.png")

    gl.button("opn4")
    gl.condition("persistent.ch04")
    gl.image("opinion4.png")

    gl.button("opn5")
    gl.condition("persistent.ch05")
    gl.image("opinion5.png")

    gl.button("opn6")
    gl.condition("persistent.ch06")
    gl.image("opinion6.png")

    gl.button("opn7")
    gl.condition("persistent.ch07")
    gl.image("opinion7.png")

    gl.button("opn8")
    gl.condition("persistent.ch08")
    gl.image("opinion8.png")

screen galleryopinion():

    tag menu

    add "/gui/game_menu.png"

    vpgrid:

        cols 8
        rows 2
        spacing 5
        draggable True

        scrollbars "horizontal" yalign -0.5
        mousewheel True

        xfill True
        yfill False

        add gl.make_button("opn1", "opinion1.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
        add gl.make_button("opn2", "opinion2.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)

        add gl.make_button("opn3", "opinion3.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
        add gl.make_button("opn4", "opinion4.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)

        add gl.make_button("opn5", "opinion5.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
        add gl.make_button("opn6", "opinion6.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)

        add gl.make_button("opn7", "opinion7.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
        add gl.make_button("opn8", "opinion8.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
        
        textbutton "Return" action Return() xalign 0.9 yalign 1.0
And the exception I get is:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "game/opinions.rpy", line 43, in execute
    screen galleryopinion():
  File "game/opinions.rpy", line 43, in execute
    screen galleryopinion():
  File "game/opinions.rpy", line 52, in execute
    vpgrid:
  File "game/opinions.rpy", line 66, in execute
    add gl.make_button("opn1", "opinion1.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
  File "game/opinions.rpy", line 66, in <module>
    add gl.make_button("opn1", "opinion1.png", locked = "/gui/lock.png", xalign=0.5, yalign=0.5)
  File "renpy/common/00gallery.rpy", line 380, in make_button
    action = self.Action(name)
  File "renpy/common/00gallery.rpy", line 333, in Action
    raise Exception("{0!r} is not a button defined in this gallery.".format(name))
Exception: u'opn1' is not a button defined in this gallery.
I feel like I must be missing something obvious, but it looks like I named the button correctly to me. I'm not really sure what else I would need to look at to troubleshoot this. Thanks!

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

Re: Exception in creating a second gallery

#2 Post by Ocelot »

I do not see two galleries here. How is the second gallery defined?
< < insert Rick Cook quote here > >

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Exception in creating a second gallery

#3 Post by hell_oh_world »

are you using different names (gl) for your galleries?

User avatar
krt_org
Newbie
Posts: 14
Joined: Wed Jul 04, 2018 7:48 pm
Contact:

[SOLVED] Re: Exception in creating a second gallery

#4 Post by krt_org »

hell_oh_world wrote: Sun Aug 01, 2021 3:12 pm are you using different names (gl) for your galleries?
That was the problem! I wasn't thinking about needing to change the name of the gallery. I only changed the name of the screen. The issue went away when I changed it. Thank you very much!

Post Reply

Who is online

Users browsing this forum: No registered users