Jumping to replay screen after a route finishes

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
InvertMouse
Regular
Posts: 95
Joined: Sat May 31, 2014 3:41 am
Completed: Unhack
Organization: InvertMouse
Location: Sydney, Australia
Contact:

Jumping to replay screen after a route finishes

#1 Post by InvertMouse » Sat Jun 06, 2015 8:43 pm

Hello there :). With the project I am working on, at the end of a route, I want to take players back to the replay screen (because it shows what screens you have cleared so players can track their progress). At the end of a route, in script.rpy, I make this call:

$ renpy.call_screen('replay_screen')

On the replay screen, I have a series of buttons that jump players to a particular scene in the game. For instance, one of the buttons will call:

Start("option_a")

I chose to call Start() rather than Replay(), as the latter prevents the save game feature from working. Anyway, this usually works fine. However, if I do the following:

- Finish a route.
- call_screen takes players to the replay screen (so they can see which ending they have just unlocked).
- Attempt to jump to a scene in the game by clicking on one of the buttons on replay screen.

If I do the above, the game crashes saying there was an exception:

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 5973, in script
$ renpy.call_screen('replay_screen')
File "game/script.rpy", line 5973, in <module>
$ renpy.call_screen('replay_screen')
File "renpy/common/00action_menu.rpy", line 128, in __call__
renpy.jump_out_of_context(self.label)
JumpOutException: option_b

After doing some research, I think I know the reason for this error. When I run $ renpy.call_screen('replay_screen'), the game is still not in the main menu context, so when I then attempt to jump to an in-game scene, Renpy tries to leave the main menu context (which the code isn't in) and becomes confused. I might be completely wrong on this, but that is my guess. Would anyone know a solution for this? Thank you :)!
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Jumping to replay screen after a route finishes

#2 Post by trooper6 » Sat Jun 06, 2015 8:52 pm

Well, call is always waiting for for the next return...which will pop you back to where you came from. In your case...to the end of that route.
Call always has a Return waiting. This does not seem to be what you want.

So try $renpy.show_screen('replay_screen')
Though I don't see why you couldn't just use the regular renpy command: show screen replay_screen
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Jumping to replay screen after a route finishes

#3 Post by xela » Sat Jun 06, 2015 8:56 pm

+

Start doesn't just "jump", it starts a completely new game...

Jump(labelname) statement actually jumps from screen to labels.
Like what we're doing? Support us at:
Image

User avatar
InvertMouse
Regular
Posts: 95
Joined: Sat May 31, 2014 3:41 am
Completed: Unhack
Organization: InvertMouse
Location: Sydney, Australia
Contact:

Re: Jumping to replay screen after a route finishes

#4 Post by InvertMouse » Sun Jun 07, 2015 8:41 am

Thank you so much for the responses! By using show screen replay_screen, the replay screen now works under every situation without the game ever crashing. However, when show screen replay_screen is called, rather than jumping to the replay screen, the game actually takes me back to the main menu. Any ideas on why that is? I would guess that after show screen replay_screen gets called, script.rpy continues to run until the end of the file, where a return will be called, taking you back to the main menu. Just a guess, though. Thank you :)!
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Jumping to replay screen after a route finishes

#5 Post by trooper6 » Sun Jun 07, 2015 11:03 am

If you want to force people to interact with your replay screen and not be able to continue on with the game from where you showed the screen, make modal True for your screen:

Code: Select all

screen replay_screen():
    modal True
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
InvertMouse
Regular
Posts: 95
Joined: Sat May 31, 2014 3:41 am
Completed: Unhack
Organization: InvertMouse
Location: Sydney, Australia
Contact:

Re: Jumping to replay screen after a route finishes

#6 Post by InvertMouse » Sun Jun 07, 2015 7:45 pm

Thanks for the tip trooper :). Unfortunately, even after adding that modal line:

screen replay_screen:

modal True

When I call:

show screen replay_screen

The game still jumps to the main menu screen instead :(.
Image

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

Re: Jumping to replay screen after a route finishes

#7 Post by philat » Sun Jun 07, 2015 8:58 pm

xela already asked this, but to put a finer point on it: why are you using Start() rather than Jump()?

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Jumping to replay screen after a route finishes

#8 Post by nyaatrap » Sun Jun 07, 2015 10:02 pm

Code: Select all

label replay():
    while True:
        call screen replay_screen
        call _return

screen replay_screen():
    button action Return("labelname")
I think this makes more sense if you don't want to use the Replay action. You can use Jump on the called screen if you want to jump to a label (it's equivalent to call screen > jump _return) rather than call.

User avatar
InvertMouse
Regular
Posts: 95
Joined: Sat May 31, 2014 3:41 am
Completed: Unhack
Organization: InvertMouse
Location: Sydney, Australia
Contact:

Re: Jumping to replay screen after a route finishes

#9 Post by InvertMouse » Mon Jun 08, 2015 4:43 am

Thanks for the further replies guys :). I found that when I use Jump() instead of Start() (from the replay screen), it seems like my save buttons are not working. In fact, for some reason, the return to title button seems to not work as well :(.
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Jumping to replay screen after a route finishes

#10 Post by trooper6 » Mon Jun 08, 2015 12:32 pm

I was just checking out the documentation for Replay()
http://www.renpy.org/doc/html/rooms.html#replay

It mentions that "Saving is disabled while in replay mode." That might be why you can't save. But looking at the documentation, I wonder, you added renpy.end_replay() right? Which leads me to realize that we've been trying to help but because you haven't posted your relevant code, we are all guessing.

Could you post the code for:

Your replay screen.
The place were you call your renpy screen.
One of the scenes you can replay.
Anything else that might be relevant.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
InvertMouse
Regular
Posts: 95
Joined: Sat May 31, 2014 3:41 am
Completed: Unhack
Organization: InvertMouse
Location: Sydney, Australia
Contact:

Re: Jumping to replay screen after a route finishes

#11 Post by InvertMouse » Mon Jun 08, 2015 4:04 pm

Yeah, for sure. Here are the relevant codes:

Replay screen:

Code: Select all

screen replay_screen:

    modal True

    tag menu

    window:
        style "mm_root"

    imagemap:
    
        ground  "assets/images/menu/replay_ground.png"
        hover  "assets/images/menu/replay_hover.png"
        insensitive  "assets/images/menu/replay_locked.png"

        hotspot (21,304,389,272) action Start("option_a")
        hotspot (455,484,362,251) action Start("option_b")

        hotspot (454,139,356,254) action If(persistent.option_a_seen == True, NullAction()) 
    
        hotspot (885,643,344,244) action If(persistent.option_b_seen == True, NullAction())
    
        hotspot (885,330,343,246) action If(persistent.option_c_seen == True, NullAction())
    
        hotspot (883,30,352,245) action If(persistent.option_d_seen == True, NullAction())
            
        hotspot (475,827,300,75) action Return()
Place where replay screen is called:

Code: Select all

label before_main_menu:

    # If you have reached an ending (rather than just jumping back to the title), run this and jump to the replay screen.

    if persistent.route_finish:
    
        scene black

        show screen replay_screen
    
    $ persistent.route_finish = False

    return
One of the scenes I replay (really not much to do this one):

Code: Select all

label option_a:

    scene test
    show test_face normal
    
    '"Is this the internet?"'
Thank you so much for helping me this far!
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Jumping to replay screen after a route finishes

#12 Post by trooper6 » Mon Jun 08, 2015 5:40 pm

So...before I get deep into your code, I think we need to step back and get a bit meta. Mainly because you complained about saving not working...which saving isn't supposed to work in replay mode.

So let me ask you what is is you really want to do.

Do you want Replay? This means: You get to replay a specific scene, you cannot save, and when done you return to you replay menu.
Do you want the player to be able to jump to a specific part of the game they have already played before and continue on from there in regular play mode? But without actually having ended the game because you want to keep all the variables that had been set up until the moment they jump to?

Side note? Why are you turning persistent.route_finish off when you show the replay menu...that seems odd since they've still finished the route, no?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Jumping to replay screen after a route finishes

#13 Post by nyaatrap » Mon Jun 08, 2015 10:54 pm

You can't use label before_main_menu. The game only starts from Start action from the main_menu. Otherwise, save/load/rollback shouldn't work.

Code: Select all

label main_menu():
    if persistent.route_finish:
        use replay_screen() # This should include Start action
    else:
        use title_screen()

Post Reply

Who is online

Users browsing this forum: Ocelot