[SOLVED]Jump to Random Label/Path/Route

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
AuthorCSR
Newbie
Posts: 14
Joined: Sat Jun 13, 2015 3:41 pm
Completed: Tints of Black, The Illness Called Love, The Devil's Alleyway
Projects: Colourful Clues
Tumblr: csrcreations
Deviantart: MonMonMouse
itch: C.S.R.
Discord: CSR Creations#6810
Contact:

[SOLVED]Jump to Random Label/Path/Route

#1 Post by AuthorCSR »

So I'm trying to figure out how to make it so that you are able to jump to a random label if the points are even in the intro.

Right now I have this at the end of the intro:

Code: Select all

    if sakiko_love >= 2:
        jump sakiko_route
    elif yoko_love >= 2:
        jump yoko_route
    elif katsumi_love >= 2:
        jump katsumi_route
    else:
        renpy.jump(random_route)

And this where my Init is:

Code: Select all

    $ random_route = ["sakiko_route", "yoko_route", "katsumi_route"]
    $ renpy.random.radiant(random_route)
 
I know that I'm definitely doing something wrong or missing something, so if I can just have a little guidance into the right direction, I'd super appreciate it!
If what I'm trying to do is not possible, please let me know that too.
Last edited by AuthorCSR on Fri Apr 20, 2018 4:30 am, edited 2 times in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Jump to Random Label/Path/Route

#2 Post by Remix »

jump expression renpy.random.choice( ["sakiko_route", "yoko_route", "katsumi_route"] )
Frameworks & Scriptlets:

User avatar
AuthorCSR
Newbie
Posts: 14
Joined: Sat Jun 13, 2015 3:41 pm
Completed: Tints of Black, The Illness Called Love, The Devil's Alleyway
Projects: Colourful Clues
Tumblr: csrcreations
Deviantart: MonMonMouse
itch: C.S.R.
Discord: CSR Creations#6810
Contact:

Re: Jump to Random Label/Path/Route

#3 Post by AuthorCSR »

I changed it to

Code: Select all

    if sakiko_love >= 2:
        jump sakiko_route
    elif yoko_love >= 2:
        jump yoko_route
    elif katsumi_love >= 2:
        jump katsumi_route
    else:
        $ variable = renpy.random.choice(["sakiko", "yoko", "katsumi"])
    if yoko:
        jump yoko_route
    elif sakiko:
        jump sakiko_route
    elif katsumi:
        jump katsumi_route
But it only seems to go with the first "if" statement.

When I had it just as

Code: Select all

    if sakiko_love >= 2:
        jump sakiko_route
    elif yoko_love >= 2:
        jump yoko_route
    elif katsumi_love >= 2:
        jump katsumi_route
    else:
        $ variable = renpy.random.choice(["sakiko_route", "yoko_route", "katsumi_route"])
It would go immediately back to the menu.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Jump to Random Label/Path/Route

#4 Post by kivik »

Can you explain what you mean by the points being even in the intro? I'm not really sure I understood what the first part of your code would achieve in relation to what you said.

Remix's example will directly jump to a random label:

Code: Select all

jump expression renpy.random.choice( ["sakiko_route", "yoko_route", "katsumi_route"] )
It's basically using the jump expression statement which jumps to whatever the string is that comes after the "jump expressions" statement.

In your revised examples, you've set the variable "variable" to the random choice but you're not checking against the variable (instead you're checking 3 different variables named yoko, sakiko and katsumi - which I assume exists elsewhere in your program or it'd crash.

The second example you've just set the variable but not executed the jump statement.

If you wanted to set the choice to a variable first, you could even do:

Code: Select all

jump expression variable
or as your original example:

Code: Select all

renpy.jump(variable)

I still don't get what this block is supposed to do though:

Code: Select all

if sakiko_love >= 2:
        jump sakiko_route
    elif yoko_love >= 2:
        jump yoko_route
    elif katsumi_love >= 2:
        jump katsumi_route
As they'd only check if the first sakiko_love is larger than 2, if not, check if yoko_love is larger than 2, and so on. They're mutually exclusive.

User avatar
AuthorCSR
Newbie
Posts: 14
Joined: Sat Jun 13, 2015 3:41 pm
Completed: Tints of Black, The Illness Called Love, The Devil's Alleyway
Projects: Colourful Clues
Tumblr: csrcreations
Deviantart: MonMonMouse
itch: C.S.R.
Discord: CSR Creations#6810
Contact:

Re: Jump to Random Label/Path/Route

#5 Post by AuthorCSR »

kivik wrote: Fri Apr 20, 2018 3:43 am Can you explain what you mean by the points being even in the intro? I'm not really sure I understood what the first part of your code would achieve in relation to what you said.
kivik wrote: Fri Apr 20, 2018 3:43 am I still don't get what this block is supposed to do though:

Thank you for getting into more detail, sorry I lacked the details.

So in the intro, you are giving three different options/choices and each time a point is given to which ever girl is favored

For example:

Code: Select all

    menu:
        "Visit Katsumi's mansion.":
            $ katsumi_love += 1
            jump kat_mansion
        "Join Sakiko in the Occult Club.":
            $ sakiko_love += 1
            jump sak_club
        "Go with Yoko to the shrine.":
            $ yoko_love += 1
            jump yo_shrine
So, when the intro is over, if a girl has at least two points, it will jump to her path. I'm trying to figure out a way for it to randomly jump to a path should they all have only one point.

User avatar
AuthorCSR
Newbie
Posts: 14
Joined: Sat Jun 13, 2015 3:41 pm
Completed: Tints of Black, The Illness Called Love, The Devil's Alleyway
Projects: Colourful Clues
Tumblr: csrcreations
Deviantart: MonMonMouse
itch: C.S.R.
Discord: CSR Creations#6810
Contact:

Re: Jump to Random Label/Path/Route

#6 Post by AuthorCSR »

Remix wrote: Thu Apr 19, 2018 7:52 pm jump expression renpy.random.choice( ["sakiko_route", "yoko_route", "katsumi_route"] )
kivik wrote: Fri Apr 20, 2018 3:43 am It's basically using the jump expression statement which jumps to whatever the string is that comes after the "jump expressions" statement.
In your revised examples, you've set the variable "variable" to the random choice but you're not checking against the variable (instead you're checking 3 different variables named yoko, sakiko and katsumi - which I assume exists elsewhere in your program or it'd crash.
The second example you've just set the variable but not executed the jump statement.

Thank you guys both! It seems that I have gotten it to work. I'm sorry, Remix, that I didn't do as what you said at first, I hadn't realized "jump expression" was a code, so that is my bad entirely.

Post Reply

Who is online

Users browsing this forum: No registered users