Others Ren'Py How do you make a label jump to a different script?

DirtyPants

Newbie
Sep 16, 2022
50
9
So I pretty much made that "Are you 18 years old" thing and this is actually my first 'game'. Took me 1 hour to make this, also it has no art right now (sigh)
Please try it and tell me if it's fine, of course, if you have anything to say go ahead.
Anyways, I gotta ask, how should I make the last label jump to a different Script?
I want to make different scripts for each scene (which will help me a lot tbh).

Also if a person who wants to start developing a game is reading this, then go ahead and use this code to study : )

Link for the game-
 
Last edited:
  • Like
Reactions: osanaiko

Mino

New Member
Aug 24, 2016
3
2
how should I make the last label jump to a different Script?
RenPy don't care much about in which file(s) your code reside. To execute code from a separate file simply jumpto a label defined in that file.
 
  • Like
Reactions: DirtyPants

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,143
14,827
[...] then go ahead and use this code to study : )
Hmm...

You don't have permission to view the spoiler content. Log in or register now.

  1. is a statement that works at init level.
    The statement should not be put into a block, whatever if it's a label or an init block. As it, it break Ren'Py , leading to an empty label, followed by an anonymous piece of code.
    You should have put it with at level 0 of indentation, and either before the first label, or between two labels.

  2. Labels are also intended to be at level 0 of indentation.
    Labels are nothing more than branching points to a new set of sequential instructions. Unlike Python functions/methods, they do not create a context that would encapsulate what is declared inside them. Therefore, putting a label into another label have absolutely no meaning, nor advantages. And of course, this will once again break the AST.
    Only could possibly be embedded into their father label ; yet only for readability purpose. Technically speaking, they should be declared right after the father label, and only there.
    Plus, like it's following a fully empty label, there's no reason to create a label here.

  3. The jump test is useless.
    You could have used the pass statement instead, and let the code continue in the same label.

  4. There's no need to jump to "well_well_well".
    The label is used only once, by the previous label, and it will be reached unconditionally. Its code could perfectly be part of the "test" label.

  5. There's no need to create a label just for a menu.
    Both the "well_well_well" and "you_donut" labels are not needed. s can double as entry point (therefore label-like) ; just give them a label name (menu myMenu:).

  6. The "lets_go" label branch no where.
    Practically speaking, it's not a problem, Ren'Py can do implicit branching ; it will just continue with the following label. But in the case of your script, this mean that players will loop endlessly between "lets_go" and "you_donut" labels.

In the end, your script should have looked like this:
Python:
define p=Character("Author",color="5995ED")

label start:

    p "Hey there, so you are here to play this game ( he said 'game' lol) ?"
    p "Well first of all thanks for downloading it, this is actually my first game so I don't know what to do lol."
    p "Oh yeah who am I? Well I am the developer of this game and my name is...DirtyPants. yep I know my name is weird, it is what it is bro."
    p "Well before we start I gotta ask some questions, Are you 18 years old?"
    menu:
        "Are you atleast 18 years old?"
        "Yes":
            pass
        "No":
            jump bruh

    p "Hmm, well I gotta test you"
    p "Your mom is not a virgin" 

    menu:
        "How do you feel after listening this"
        "I know bruh" :
            "Noice, this means your a mature individual. Well lets begin this then"
            jump startTheGame
        "What does virgin mean?" :
            menu:
                "Nice start, well virgin means someone who's had sex"
                "Oh okay, yeah I know lets go":
                    jump startTheGame
                "What does sex mean":
                    jump bruh

label bruh:
    p "Yeah you gotta bro"
    p "Go play mario bro, we will talk next time when you are 18"
    return

label startTheGame:
    "Whatever you want from here"
 
  • Like
Reactions: DirtyPants

DirtyPants

Newbie
Sep 16, 2022
50
9
Hmm...

You don't have permission to view the spoiler content. Log in or register now.

  1. is a statement that works at init level.
    The statement should not be put into a block, whatever if it's a label or an init block. As it, it break Ren'Py , leading to an empty label, followed by an anonymous piece of code.
    You should have put it with at level 0 of indentation, and either before the first label, or between two labels.

  2. Labels are also intended to be at level 0 of indentation.
    Labels are nothing more than branching points to a new set of sequential instructions. Unlike Python functions/methods, they do not create a context that would encapsulate what is declared inside them. Therefore, putting a label into another label have absolutely no meaning, nor advantages. And of course, this will once again break the AST.
    Only could possibly be embedded into their father label ; yet only for readability purpose. Technically speaking, they should be declared right after the father label, and only there.
    Plus, like it's following a fully empty label, there's no reason to create a label here.

  3. The jump test is useless.
    You could have used the pass statement instead, and let the code continue in the same label.

  4. There's no need to jump to "well_well_well".
    The label is used only once, by the previous label, and it will be reached unconditionally. Its code could perfectly be part of the "test" label.

  5. There's no need to create a label just for a menu.
    Both the "well_well_well" and "you_donut" labels are not needed. s can double as entry point (therefore label-like) ; just give them a label name (menu myMenu:).

  6. The "lets_go" label branch no where.
    Practically speaking, it's not a problem, Ren'Py can do implicit branching ; it will just continue with the following label. But in the case of your script, this mean that players will loop endlessly between "lets_go" and "you_donut" labels.

In the end, your script should have looked like this:
Python:
define p=Character("Author",color="5995ED")

label start:

    p "Hey there, so you are here to play this game ( he said 'game' lol) ?"
    p "Well first of all thanks for downloading it, this is actually my first game so I don't know what to do lol."
    p "Oh yeah who am I? Well I am the developer of this game and my name is...DirtyPants. yep I know my name is weird, it is what it is bro."
    p "Well before we start I gotta ask some questions, Are you 18 years old?"
    menu:
        "Are you atleast 18 years old?"
        "Yes":
            pass
        "No":
            jump bruh

    p "Hmm, well I gotta test you"
    p "Your mom is not a virgin"

    menu:
        "How do you feel after listening this"
        "I know bruh" :
            "Noice, this means your a mature individual. Well lets begin this then"
            jump startTheGame
        "What does virgin mean?" :
            menu:
                "Nice start, well virgin means someone who's had sex"
                "Oh okay, yeah I know lets go":
                    jump startTheGame
                "What does sex mean":
                    jump bruh

label bruh:
    p "Yeah you gotta bro"
    p "Go play mario bro, we will talk next time when you are 18"
    return

label startTheGame:
    "Whatever you want from here"
Also if a person who wants to start developing a game is reading this, then go ahead and use this code to study : )
Well this is awkward for me but still thanks for pointing out these things.

And we'll about point 6 of yours, Was going to continue using jump to a different script as I said above.

But yeah, you made this code way simpler. You have my thanks, Senpai
 
Last edited:

DirtyPants

Newbie
Sep 16, 2022
50
9
label bruh: p "Yeah you gotta bro" p "Go play mario bro, we will talk next time when you are 18" return
hey so I reviewing this code, and I gotta ask. Why is there a return statement there?
I tried deleting the return and launching the game, it works.
Will appreciate it if you can tell : )
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,143
14,827
hey so I reviewing this code, and I gotta ask. Why is there a return statement there?
Because, like I said, without a branching statement to end a label, Ren'Py will just branch to what is following.

Therefore, without the return, that here send back to the main menu, the "bruh" label would just be another entry point to the game. After its last line, Ren'Py would continue by processing the "startTheGame" label.
 
  • Like
Reactions: DirtyPants