[SOLVED] Make "return" statement return to Extra screen, NOT main menu?

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
Black Cat 2412
Regular
Posts: 57
Joined: Wed Aug 16, 2017 10:10 am
Deviantart: BlackCat2412
Location: Vietnam
Contact:

[SOLVED] Make "return" statement return to Extra screen, NOT main menu?

#1 Post by Black Cat 2412 » Wed Sep 13, 2017 2:28 pm

Good day ladies and gentlemen

I'm having this Epilogue that can only be accessed through the Extra screen. I want to make it so that when the player finish reading the Epilouge, they will be taken back to the Extra screen, NOT the Main Menu. Here is the code of the Epilogue scene:

Code: Select all

label epi:

    c "This is where I put my Epilogue. It can only be accessed through the Extra screen."
     
    return  ##I want this return statement to take the player back to the Extra screen, NOT the main menu
and here is the code for the Extra screen (nothing special about it, I put it in just in case)

Code: Select all

screen extra():

    tag menu

    ## This use statement includes the game_menu screen inside this one. 
    use game_menu(_("Extra")):

        style_prefix "extra"

        vbox:
            textbutton _("{size=50}Epilogue{/size}") action Start("epi") xpos 240 ypos 100
            textbutton _("{size=50}Image Gallery{/size}") actionShowMenu("gallery") xpos 240 ypos 150
          


style extra_label is gui_label
style extra_label_text is gui_label_text
style extra_text is gui_text

style extra_label_text:
    size gui.label_text_size
Thank in advance
Last edited by Black Cat 2412 on Thu Sep 14, 2017 5:14 am, edited 1 time in total.

User avatar
TellerFarsight
Regular
Posts: 180
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Reverse-Engineering "Devil Survivor", "Forsaken Wish", "Silent Thrills", "Secrets Untold", "Girlfriend Material"
Location: Toronto, ON
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#2 Post by TellerFarsight » Wed Sep 13, 2017 2:54 pm

The return statement goes back to the main menu because you go to the "epi" label with Start(). It can't really return to the menu that way, because it's not really recording the extra screen as an intermediary. If you call a label, return will take you back to where it was called from, but I don't know for sure if it'll work to Function(renpy.call, "epi"). The other solution would be to not return from the epilogue, but to jump from it to something else. Maybe end the epilogue with a jump to another label, where the extra screen is shown.
Current RevEng Project: Devil Survivor [Reverse-Engineered]
Original Projects for which I'm Recruiting: Vora and Escape the Vroom!!!!!!

User avatar
Black Cat 2412
Regular
Posts: 57
Joined: Wed Aug 16, 2017 10:10 am
Deviantart: BlackCat2412
Location: Vietnam
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#3 Post by Black Cat 2412 » Wed Sep 13, 2017 3:43 pm

Thank for your reply.
Did you mean something like this? (sorry if I got it wrong):

Code: Select all

label epi:
    c "This is where I put my Epilogue. It can only be accessed through the Extra screen."
    jump epi_return
    
label epi_return:
    show screen extra
It would cause an error if I go into the epilogue once again:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 275, in script
    menu:
  File "renpy/common/00action_menu.rpy", line 141, in __call__
    renpy.jump_out_of_context(self.label)
JumpOutException: epi

Another approach I can think of (but don't know how to code it) is something like this:

Code: Select all

label epi:
    c "This is where I put my Epilogue. It can only be accessed through the Extra screen."
    $ persistent.epi==True
    return
And then, in the main menu screen:

Code: Select all

screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu

    style_prefix "main_menu"

    #The background image
    add "gui/main_menu.png"
    use navigation
    
    ## Make it so that if the player go to the main menu from the epilogue, it will automatically open the Extra screen:
    if persistent.epi == None:
        pass
    elif persistent.epi == True:
        ShowMenu('extra')
        $ persistent.epi = None
        
This of course did not work:

Code: Select all

File "game/screens.rpy", line 493: u'ShowMenu' is not a keyword argument or valid child for the screen statement.
    ShowMenu('extra')
but that's the general idea.
Last edited by Black Cat 2412 on Wed Sep 13, 2017 3:57 pm, edited 1 time in total.

User avatar
TellerFarsight
Regular
Posts: 180
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Reverse-Engineering "Devil Survivor", "Forsaken Wish", "Silent Thrills", "Secrets Untold", "Girlfriend Material"
Location: Toronto, ON
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#4 Post by TellerFarsight » Wed Sep 13, 2017 3:53 pm

I'm not really sure what the problem is in the first case. Can you label which one is line 275?
In the second case, I think if you put
use "extra"
or something like that, instead of ShowMenu, that might work.
Current RevEng Project: Devil Survivor [Reverse-Engineered]
Original Projects for which I'm Recruiting: Vora and Escape the Vroom!!!!!!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#5 Post by Divona » Wed Sep 13, 2017 10:02 pm

How about using Replay?

Code: Select all

screen extra():

    tag menu

    ## This use statement includes the game_menu screen inside this one. 
    use game_menu(_("Extra")):

        style_prefix "extra"

        vbox:
            textbutton _("{size=50}Epilogue{/size}") action Replay("epi", locked=False) xpos 240 ypos 100
            textbutton _("{size=50}Image Gallery{/size}") action ShowMenu("gallery") xpos 240 ypos 150

    . . .

Code: Select all

label epi:

    c "This is where I put my Epilogue. It can only be accessed through the Extra screen."
     
    $ renpy.end_replay()  ## End replay and return to wherever menu it came from.
Completed:
Image

philat
Eileen-Class Veteran
Posts: 1224
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#6 Post by philat » Wed Sep 13, 2017 10:15 pm

Replay should work, but if you need to use Start(), you could try using renpy.full_restart with the target set to the extra menu. https://www.renpy.org/doc/html/other.ht ... ll_restart

User avatar
Black Cat 2412
Regular
Posts: 57
Joined: Wed Aug 16, 2017 10:10 am
Deviantart: BlackCat2412
Location: Vietnam
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#7 Post by Black Cat 2412 » Thu Sep 14, 2017 4:31 am

Thank, but I think I will use Replay for the epilogue for now (I did not know that I could set locked= False like that, ha ha - such a noob).

While we are on the topic, may I ask how to make the "Return" button of the CG gallery also return to the Extra screen as well?

Code: Select all

screen gallery(): # <==== Can only be accessed via the Extra screen

    tag menu
    add "gui/game_menu.png"

    # Call make_button to show a particular button.

    add g.make_button("Gallery_b_1", locked="CG/CGb_lock.jpg", unlocked= "CG/CGb_1.jpg", xpos = 110, ypos = 70, xsize= 300, ysize = 160) 
    add g.make_button("Gallery_b_2", locked="CG/CGb_lock.jpg", unlocked= "CG/CGb_2.jpg", xpos = 490, ypos = 70, xsize= 300, ysize = 160)
    add g.make_button("Gallery_b_3", locked="CG/CGb_lock.jpg", unlocked= "CG/CGb_lock.jpg", xpos = 870, ypos = 70)
   

    # The return button <===  How Can I make it go back to the Extra, not the Main menu?
    textbutton "Return" action Return() xalign 0.5 ypos 0.9
P/S: I tried my aforementioned second method with: use "extra" - It simply did not have any effect at all.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#8 Post by Divona » Thu Sep 14, 2017 4:59 am

Black Cat 2412 wrote:
Thu Sep 14, 2017 4:31 am
While we are on the topic, may I ask how to make the "Return" button of the CG gallery also return to the Extra screen as well?
By default, Return should return to wherever the previous screen that the new screen came from. Extra -> Gallery, it should just return back to extra. Doesn't it do that in this case?

EDIT: I see you using "game_menu", the return button is already built in, so Return would simply return back to main menu.
Last edited by Divona on Thu Sep 14, 2017 5:08 am, edited 2 times in total.
Completed:
Image

User avatar
Imperf3kt
Miko-Class Veteran
Posts: 993
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#9 Post by Imperf3kt » Thu Sep 14, 2017 5:05 am

I thought "return" returned to the start of the call stack, ie, the main menu.
https://www.renpy.org/doc/html/screen_a ... ml?#Return
Causes the current interaction to return the supplied value, which must not be None. This is often used with menus and imagemaps, to select what the return value of the interaction is. If the screen was called using the call screen statement, the return value is placed in the _return variable.
When in a menu, this returns from the menu. (The value should be None in this case.)
Just use a Show("menuname")
or ShowMenu("menuname")
https://www.renpy.org/doc/html/screen_a ... nu-actions

For example, I use something like this:

Code: Select all

imagebutton alt "back" hover "gui/button/back.png" idle "gui/button/back.png" focus_mask True action ShowMenu("extras")
Without this, using just

Code: Select all

imagebutton alt "return" hover "gui/button/return.png" idle "gui/button/return.png" focus_mask True action Return()
returns me to the main menu instead of the previous menu I came from.

E: Sorry, this is referencing screen language. Probably unrelated.
Last edited by Imperf3kt on Thu Sep 14, 2017 5:30 am, edited 2 times in total.
Image

Warning: May contain trace amounts of gratuitous plot.

User avatar
Black Cat 2412
Regular
Posts: 57
Joined: Wed Aug 16, 2017 10:10 am
Deviantart: BlackCat2412
Location: Vietnam
Contact:

Re: Make "return" statement return to Extra screen, NOT main menu?

#10 Post by Black Cat 2412 » Thu Sep 14, 2017 5:13 am

Thank a lot!
Why did I not think of ShowMenu("extra") in the first place? It was so simple! (-‸ლ)

Thank all of you for replying, you guy are so great!

Post Reply

Who is online

Users browsing this forum: No registered users