[Solved] Story/chapter selection - Very confused please help

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.
Message
Author
User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

[Solved] Story/chapter selection - Very confused please help

#1 Post by SethRiley »

Greetings fellow RenPy enthousiasts. I am new to both Renpy and this forum, please forgive me if my question seems ill-advised.

I am trying to make a visual novel consisting of 8 short stories, which are immediately accessible through a story/chapter select screen. The user first gets presented a title screen, which is the main menu. An image button there brings up the chapter screen.

from screens.rpy:

Code: Select all

imagebutton idle "gui/start.png" xpos 110 ypos 320 action Show("chapter", transition=dissolve)

Code: Select all

screen chapter():

    tag menu

    style_prefix "chapter_menu"

    add gui.chapter_menu_background

    imagebutton idle "gui/chapter1_button.png" xpos 24 ypos 24 action Start("story01")
    imagebutton idle "gui/chapter2_button.png" xpos 336 ypos 24 action Start("story02")
    imagebutton idle "gui/chapter3_button.png" xpos 648 ypos 24action Start("story03")
    imagebutton idle "gui/chapter4_button.png" xpos 960 ypos 24 action Start("story04")
    imagebutton idle "gui/chapter5_button.png" xpos 24 ypos 336 action Start("story05")
    imagebutton idle "gui/chapter6_button.png" xpos 336 ypos 336 action Start("story06")
    imagebutton idle "gui/chapter7_button.png" xpos 648 ypos 336 action Start("story07")
    imagebutton idle "gui/chapter8_button.png" xpos 960 ypos 336 action Start("story08")

    imagebutton idle "gui/back.png" xpos 12 ypos 639 action Show("main_menu", transition=dissolve)
This story selection screen has 8 different image buttons, which lead to 8 different labels in the script.

from script.rpy

Code: Select all

init:
    image white = Solid((255, 255, 255, 255))
    image splash = "gui/splash.png"
    image bg room = "gui/room.png"

label splashscreen:
    
    scene white
    with Pause(0.5)
    show splash at Position(xpos = 0.5, xanchor=0.5, ypos=0.5, yanchor=0.5) with dissolve
    with Pause(2.5)
    scene white with dissolve
    with Pause(1)
    return

label story01:

    show bg room
    "Bla bla."
    "Bla bla bla."
    hide bg room
    return

label story02:
    ...

label story08:
    ...
etc.
So far so good. However, after a story ends, the user ends up back at the main menu.

I would like to have the user brought back to the story select (chapter) screen instead. How can this be achieved?
Last edited by SethRiley on Sun Mar 19, 2017 12:38 am, edited 1 time in total.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#2 Post by SuperbowserX »

replace the "return" line of code that ends the story with a command that says "jump chapterselectmenu"

then, place a "label chapterselectmenu:" line of code immediately before the chapter select menu. and no you don't need to indent everything under that line of code

:)

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#3 Post by SethRiley »

Thanks for the reply SuperbowserX.

That would indeed solve it. However, the chapter screen is within screens.rpy. Should this chapter screen be moved over to script.rpy and labeled ? Or should the label in script.rpy link to the screen?

I tried putting "jump chapterselectmenu" at the end of each story, and creating a label in script.rpy that makes use of the call screen funtion.

Code: Select all

label chapterselectmenu:
    
    call screen chapter
This seems to work at first glance. After the splash screen the user is presented the title screen (main menu), which has a button leading to the chapter select screen. From there, the user can choose and read a story, after which he ends back at the chapter select screen.

A crash occurs whenever the user then chooses to read the same or another story (ie: the second time reading a story).
While running game code:
File "game/script.rpy", line 40, in script
call screen chapter
File "renpy/common/000statements.rpy", line 471, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_menu.rpy", line 141, in __call__
renpy.jump_out_of_context(self.label)
JumpOutException: story01
What is the right approach to solving this?

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#4 Post by SuperbowserX »

For the record, you can divide your project into as many .rpy files as you want (I myself do this for all of my game's chapters). All of your .rpy files can access labels, variables, screens etc. in your other files; Ren'py essentially merges them into one giant project :)

Anyway, I've never seen that error before. Try googling "jumpoutofexception" renpy for more help. Good luck!

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

Re: Story/chapter selection - Very confused, please help

#5 Post by Ocelot »

You need to exit first story (by return statement) before starting second. Do not call Start when a game is already running. I will probably write something in the morning (+10h from now).
< < insert Rick Cook quote here > >

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#6 Post by SethRiley »

Thanks SuperbowserX. Googling the error doesn't seem to yield helpful results though. This error should probably be avoided entirely by not making use of the call screen function in that manner.

RenPy indeed merges the code in the end, but doesn't simply accept lines from screens.rpy to be copied over to script.rpy or vice versa.

Ocelot, I see where you are coming from, that makes a lot of sense. A story would indeed need to be ended first with a return statement, which normally brings the user back to the main menu. How could one end up back at the chapter select screen instead? It is defined as "screen chapter():" within screens.rpy. Might as well have been any other screen though, for example "screen about():" or "screen preferences():"
Looking forward to your reply in the morning. Good night for now Ocelot (^_^)/

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#7 Post by SuperbowserX »

Try this. Make, after your "label start" (you do have one, right?), another label with a basic opening message. Try to do this:

Code: Select all

label chapterselectmenu:
"Welcome to the chapter select menu!"
"What would you like to play?"
show screen chapter
Then, at the end of your stories, maybe do a fade to black (so it's clear you exited the story, then do the "jump chapterselectmenu" command. The idea is that both your starting point in the game (after the splashscreen), and your jump point, will arrive at this chapterselectmenu label.

I don't use the return statement for anything. My chapters all just return to the menu (or give an option to restart/next chapter) at they're end. I recommend you do the same.

Test this out. Does it work?

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#8 Post by SethRiley »

Thanks again SuperbowserX. I tried the method you describe, which seems solid and would likely work if the stories weren't triggered through the use of "action Start("story01")".

It seems that whenever a story (or any other label such as the splash screen) is set in progress that way, it must be ended first with a return statement, before another label can be started.

I have been studying https://www.renpy.org/doc/html/label.ht ... of_context and other documentation for the past hours, trying to figure out a way to set this up properly.

Currently I have the main menu call the chapter select screen:

Code: Select all

label main_menu:
    
    call screen chapter()
This way all stories can be read just fine, though the game insists on always starting at the chapter select screen, also when the game has first started up. The title screen (main_menu) is skipped entirely, but still accessible with the back button at the chapter select screen.

This is naturally not how it should be though. Still figuring out a way...

How do you "start" your chapters SuperbowserX? How do you direct toward those labels, and from where? Do you use text or image buttons perhaps?

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#9 Post by SethRiley »

I just though I had cracked it by using "if renpy.seen_label()":

Code: Select all

label main_menu:
    
    if renpy.seen_label("ender"):
        call screen chapter()
    else:
        call screen main_menu()
At the end of each story I put "jump ender", and at the end of script.rpy I put

Code: Select all

label ender:
    
    return
This seems to work like a dream, but only for the duration of one game session. Whenever the user quits the entire game and starts it back up, he gets the chapter select screen presented again immediately after the splash screen. Deleting the saves, cache and persistent data associated with the game fixes this, but yet again this can't be how it's supposed to work.
Last edited by SethRiley on Sun Mar 19, 2017 12:57 am, edited 2 times in total.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#10 Post by SuperbowserX »

I have an idea. Instead of using Start as your action, try using jump to jump to those labels. I don't know what the difference is but it may work.

Code: Select all

    imagebutton idle "gui/chapter1_button.png" xpos 24 ypos 24 action Start("story01")
Is changed to:

Code: Select all

    imagebutton idle "gui/chapter1_button.png" xpos 24 ypos 24 action Jump("story01")

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: Story/chapter selection - Very confused, please help

#11 Post by SethRiley »

YES SuperbowserX! That totally works :D

By using "action Jump" instead of "action Start" there initially is no need for a return statement, and the method gets way less convoluted.

Now all stories simply end in a "return", and the main_menu is called from within the splash screen.

Code: Select all

label splashscreen:
    
    scene white
    with Pause(0.5)
    show splash at Position(xpos = 0.5, xanchor=0.5, ypos=0.5, yanchor=0.5) with dissolve
    with Pause(2.5)
    scene white with dissolve
    with Pause(1)
    call screen main_menu()
    return

label main_menu:
    
    call screen chapter()
    return

label start:

    return
This way the game starts up normally, displaying a splash screen, followed by a title screen, which has a button leading to a story select screen. After finishing a story, the user ends up at the story select screen again. This is how the application should ideally behave.

Thanks a lot SuperbowserX. This has been my first topic at this forum, and you have been the first to provide me with a solution to a RenPy problem. Much appreciated.

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

Re: [Solved] Story/chapter selection - Very confused please

#12 Post by Ocelot »

I'm glad, that you have found an answer to your question. I must warn you: this is not a proper way to start a game and it messes up some of internal renpy bookkeeping. You probably would be fine, unless you use some more advanced RenPy features. In particular I suggest to text saving/loading. Extensively.
< < insert Rick Cook quote here > >

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: [Solved] Story/chapter selection - Very confused please

#13 Post by SethRiley »

Hey good morning Ocelot (^_^)/

Yeah this seems unorthodox, though it does the trick. Luckily it is a simple application, no saving/loading involved.

Thanks for your help and input Ocelot.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: [Solved] Story/chapter selection - Very confused please

#14 Post by SuperbowserX »

hey ocelot, i'd appreciate an elaboration, why is this considered unorthodox?

User avatar
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Re: [Solved] Story/chapter selection - Very confused please

#15 Post by SethRiley »

I am also very curious regarding what would be the *proper* way to achieve this. Feel free to explain or suggest Ocelot, I would like to test it.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]