[SOLVED] Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

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
Rinzamakani
Regular
Posts: 74
Joined: Wed Aug 16, 2017 3:23 pm
Completed: Love's Apathy (Ciro route), A Frigid Space, Telechronic Static
Projects: Love's Apathy (Full)
itch: rinzamakani.itch.io
Contact:

[SOLVED] Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#1 Post by Rinzamakani »

Hello. I've been trying and searching around for a way to make the bonus screen to my game return to the gallery screen, NOT the main menu. Everything I've looked up and tried gives me different error screens.

I don't use imagemaps.

What I've tried:

Code: Select all

$ renpy.game_menu("gallery")
This gives an error.

Code: Select all

$ renpy.call_screen("gallery")
This one also gives an error.

Code: Select all

return
Same for this one.

Code: Select all

textbutton ("Return to Gallery") action [Return(), Hide("bonuscontent")]
This one in specific returns to the game itself, not the gallery screen.

Here is the code for the bonus content screen:

Code: Select all

screen bonuscontent():
   tag menu
   use game_menu(_("Bonus Content"), scroll="viewport"):
        vbox:
            xalign 1.0
            xoffset 30
            xmaximum 1100
            yalign 1.0
            yoffset 30
            textbutton _("Profiles") action ShowMenu("profiles")
            textbutton _("Endings") action ShowMenu("Ending_gallery")
            textbutton _("Afterword") action Show("afterword")
If possible, I'd like to use the same return code for the other screens as well, such as profiles being able to go back to the bonus content screen.

My renpy version is 7.3.5.606

Thank you. :)
Last edited by Rinzamakani on Wed Aug 25, 2021 9:15 pm, edited 1 time in total.

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

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#2 Post by Ocelot »

Did you try

Code: Select all

textbutton ("Return to Gallery") action ShowMenu("gallery")
?
< < insert Rick Cook quote here > >

User avatar
Rinzamakani
Regular
Posts: 74
Joined: Wed Aug 16, 2017 3:23 pm
Completed: Love's Apathy (Ciro route), A Frigid Space, Telechronic Static
Projects: Love's Apathy (Full)
itch: rinzamakani.itch.io
Contact:

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#3 Post by Rinzamakani »

Ocelot wrote: Wed Aug 25, 2021 1:26 pm Did you try

Code: Select all

textbutton ("Return to Gallery") action ShowMenu("gallery")
?
That gives me this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/gallery.rpy", line 42, in execute
    screen gallery():
  File "game/gallery.rpy", line 42, in execute
    screen gallery():
  File "game/gallery.rpy", line 49, in execute
    if cg_page == 1:
  File "game/gallery.rpy", line 51, in execute
    grid 3 3:
  File "game/gallery.rpy", line 61, in execute
    add g.make_button("Gallery_Button_Name", "Gallery_Image_Thumbnail.png", "Gallery_Locked_Thumbnail.png")
  File "renpy/common/00gallery.rpy", line 382, in make_button
    action = self.Action(name)
  File "renpy/common/00gallery.rpy", line 335, in Action
    raise Exception("{0!r} is not a button defined in this gallery.".format(name))
Exception: u'Gallery_Button_Name' is not a button defined in this gallery.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\ui.py", line 297, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 3094, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\screen.py", line 430, in visit_all
    callback(self)
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\core.py", line 3094, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\screen.py", line 440, in per_interact
    self.update()
  File "C:\Users\Rin\Documents\renpy-6.99.13-sdk\renpy\display\screen.py", line 625, in update
    self.screen.function(**self.scope)
  File "game/gallery.rpy", line 42, in execute
    screen gallery():
  File "game/gallery.rpy", line 42, in execute
    screen gallery():
  File "game/gallery.rpy", line 49, in execute
    if cg_page == 1:
  File "game/gallery.rpy", line 51, in execute
    grid 3 3:
  File "game/gallery.rpy", line 61, in execute
    add g.make_button("Gallery_Button_Name", "Gallery_Image_Thumbnail.png", "Gallery_Locked_Thumbnail.png")
  File "<screen language>", line 61, in <module>
  File "renpy/common/00gallery.rpy", line 382, in make_button
    action = self.Action(name)
  File "renpy/common/00gallery.rpy", line 335, in Action
    raise Exception("{0!r} is not a button defined in this gallery.".format(name))
Exception: u'Gallery_Button_Name' is not a button defined in this gallery.

Windows-8-6.2.9200
Ren'Py 7.3.5.606
Game 2.0
Wed Aug 25 14:16:11 2021

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

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#4 Post by Ocelot »

This is completely unrelated and points to error in the gallery screen.
< < insert Rick Cook quote here > >

User avatar
Rinzamakani
Regular
Posts: 74
Joined: Wed Aug 16, 2017 3:23 pm
Completed: Love's Apathy (Ciro route), A Frigid Space, Telechronic Static
Projects: Love's Apathy (Full)
itch: rinzamakani.itch.io
Contact:

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#5 Post by Rinzamakani »

Ocelot wrote: Wed Aug 25, 2021 5:04 pm This is completely unrelated and points to error in the gallery screen.
I'm not entirely sure what could be wrong then. Here's the code to the gallery:

Code: Select all

init python:

    g = Gallery()

    ## Edit this with your stuff and create the rest according to tutorial.
    g.button("Button_Name")
    g.unlock_image("CG_Image")

    g.transition = dissolve

screen gallery_navigation():

    ## Change with your image
    add "images/whatever.png"

    vbox:
        style_prefix "gallery_nav"

        ## Gallery Navigation to Character A, Character B and Character C gallery.
        textbutton _("Ch1") action Show("gallery_a")
        textbutton _("Ch2") action Show("gallery_b")
        textbutton _("Ch3") action Show("gallery_c")
        textbutton _("Bonuses") action Show("bonuscontent")
        textbutton _("Glossary") action Show("dictionary")

    textbutton _("{b}Return{/b}") action [Return(), Hide("gallery_navigation")] xalign 0.00 yalign 0.95

## The position of the vertical box containing the gallery navigation buttons
style gallery_nav_vbox:
    xalign 0.003
    yalign 0.5
    spacing 40

screen gallery_a():

    default cg_page_a = 1

    zorder 100
    tag menu

    hbox:
        style_prefix "gallery_stuff"

        ## Our buttons for the pages of Character A's Gallery section.
        textbutton _("1") action SetLocalVariable("cg_page_a", 1)
        textbutton _("2") action SetLocalVariable("cg_page_a", 2)

    showif cg_page_a == 1:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            add g.make_button("CG1_Button", "images/ch11cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG2_Button", "images/ch12cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG3_Button", "images/ch14cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG4_Button", "images/ch13cgthumb.png", "images/thumbnail_locked.png")

    elif cg_page_a == 2:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            add g.make_button("CG5_Button", "images/ch1cg.png", "images/thumbnail_locked.png")
            add g.make_button("CG6_Button", "images/ch1thumb.png", "images/thumbnail_locked.png")
            null
            null

screen gallery_b():

    default cg_page_b = 1

    zorder 100
    tag menu

    hbox:
        style_prefix "gallery_stuff"

        ## Our buttons for the pages of Character B's Gallery section.
        textbutton _("1") action SetLocalVariable("cg_page_b", 1)
        textbutton _("2") action SetLocalVariable("cg_page_b", 2)

    showif cg_page_b == 1:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            add g.make_button("CG7_Button", "images/ch31cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG8_Button", "images/ch32cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG9_Button", "images/ch33cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG10_Button", "images/ch34cgthumb.png", "images/thumbnail_locked.png")

    elif cg_page_b == 2:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            add g.make_button("CG11_Button", "images/ch35cgthumb.png", "images/thumbnail_locked.png")
            add g.make_button("CG12_Button", "images/ch36cgthumb.png", "images/thumbnail_locked.png")
            null
            null

screen gallery_c():

    default cg_page_c = 1

    zorder 100
    tag menu

    hbox:
        style_prefix "gallery_stuff"

        ## Our buttons for the pages of Character C's Gallery section.
        textbutton _("1") action SetLocalVariable("cg_page_c", 1)
        textbutton _("2") action SetLocalVariable("cg_page_c", 2)

    showif cg_page_c == 1:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            null
            null
            null
            null

    elif cg_page_c == 2:
        grid 2 2:
            style_prefix "gallery_stuff"

            ## Replace one null with one button created according to this structure:
            ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
            null
            null
            null
            null

style gallery_nav_vbox:
    xalign 0.003
    yalign 0.5
    spacing 40

screen gallery_d():

    default cg_page_d = 1

    zorder 100
    tag menu

    hbox:
        style_prefix "gallery_stuff"

        ## Our buttons for the pages of Character A's Gallery section.
        textbutton _("1") action SetLocalVariable("cg_page_d", 1)
        textbutton _("2") action SetLocalVariable("cg_page_d", 2)

        showif cg_page_d == 1:
            grid 2 2:
                style_prefix "gallery_stuff"

                ## Replace one null with one button created according to this structure:
                ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
                null
                null
                null
                null

        elif cg_page_d == 2:
            grid 2 2:
                style_prefix "gallery_stuff"

                ## Replace one null with one button created according to this structure:
                ## add g.make_button("CG_Button_Name", "path/Unlocked_Thumbnail.png", "path/Locked_Thumbnail.png")
                null
                null
                null
                null

## The position of our gallery images.
style gallery_stuff_grid:
    xalign 0.5
    yalign 0.5
    xspacing 20
    yspacing 20

## The position of the page-buttons.
style gallery_stuff_hbox:
    xalign 0.5
    yanchor 0.9
    ypos 0.95
    xspacing 10

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#6 Post by rayminator »

did you change Ocelot code gallery to gallery_navigation?

so it would be like this textbutton ("Return to Gallery") action ShowMenu("gallery_navigation")

User avatar
Rinzamakani
Regular
Posts: 74
Joined: Wed Aug 16, 2017 3:23 pm
Completed: Love's Apathy (Ciro route), A Frigid Space, Telechronic Static
Projects: Love's Apathy (Full)
itch: rinzamakani.itch.io
Contact:

Re: Making bonus content screen return to gallery screen, not main menu? Not using imagemaps

#7 Post by Rinzamakani »

rayminator wrote: Wed Aug 25, 2021 8:24 pm did you change Ocelot code gallery to gallery_navigation?

so it would be like this textbutton ("Return to Gallery") action ShowMenu("gallery_navigation")
Thank you very much! Turns out the code was:

Code: Select all

textbutton _("Return to Gallery") action [ShowMenu("gallery_navigation"), Show("gallery_a")]
Thank you both for the help! It's highly appreciated! :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], SONTSE