Page 1 of 1

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

Posted: Wed Sep 13, 2017 2:28 pm
by Black Cat 2412
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

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

Posted: Wed Sep 13, 2017 2:54 pm
by TellerFarsight
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.

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

Posted: Wed Sep 13, 2017 3:43 pm
by Black Cat 2412
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.

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

Posted: Wed Sep 13, 2017 3:53 pm
by TellerFarsight
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.

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

Posted: Wed Sep 13, 2017 10:02 pm
by Divona
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.

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

Posted: Wed Sep 13, 2017 10:15 pm
by philat
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

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

Posted: Thu Sep 14, 2017 4:31 am
by Black Cat 2412
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.

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

Posted: Thu Sep 14, 2017 4:59 am
by Divona
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.

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

Posted: Thu Sep 14, 2017 5:05 am
by Imperf3kt
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.

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

Posted: Thu Sep 14, 2017 5:13 am
by Black Cat 2412
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!