Unlockable 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
Ixica
Newbie
Posts: 2
Joined: Sat Mar 22, 2014 11:39 am
Contact:

Unlockable Route

#1 Post by Ixica »

Hi, sorry if this has been asked before, but I really need some clarification on how to get an unlockable route going.

The deal is, I have three route ends in my game, and the one unlockable. I want the unlockable route to, well, unlock only after you've gotten all three normal ends, and so you can choose to select that route right off the bat at the beginning of the game.

I've read up on persistent data, and I tried fiddling around with it, but I'm just not entirely sure what I'm doing, exactly. I'm a bit more than a super newbie to Ren'Py and Python alike. So this might seem a bit stupid or obvious to most people.

I guess in brief, I'm asking, how might I pull this off so that the game knows when you've gotten all three ends, what exact code do I need exactly to trigger a permanent flag for each end and for the verification process, and where exactly do I put all this? Do I need to edit another .py file other than script.py for it to work? Thanks in advance.

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Unlockable Route

#2 Post by Destiny »

It's quite simple: use statements
Create three statements at the veeeeeeeery beginning of script.rpy under init and set them to false:

Code: Select all

init:
        $ A_done = False
        $ B_done = False
        $ C_done = False
Then, upon archieving the end of a route, set

Code: Select all

$ A_done = True
Important: It has to be BEFORE the game restarts, so best do it somewhere in the final dialogue, so it gets definitly activated.
Of course, each ending has its own statement ;)

Then, finally do this:

Code: Select all

if A_done and B_done and C_done:
        e "Good work!"
        return
    else:
        e "Try again!"
        return
If all three statements are active, then the additional route will unlock (Good work!), if one of them is missing, you have to keep going (try again).

WHERE you put the verification depends on how your game works.
If you do it by creating a menu, then it looks something like this:

Code: Select all

if A_done and B_done and C_done:
        menu:
            "Meet unlockable dude":
                jump u
            "Meet dude A":
                jump a
            Meet dude B":
                jump b
            "Meet dude C":
                jump c
else:
        menu:
            "Meet dude A":
                jump a
            "Meet dude B":
                jump b
            "Meet dude C":
                jump c
Important on the last bit is, that you need to use "and" between the statements, so Ren'Py understands, that ALL of them are needed.

Alternatively: if ANY ending will do, use a colon.

Code: Select all

if A_done, B_done, C_done:
        e "Good work!"
        return
This way, you get a positive response as long as ONE of the listed ones is active (in case, that is relevant).
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Unlockable Route

#3 Post by saguaro »

For persistent variables, you'll want to set up something like this in an init block.

Code: Select all

init:
    if persistent.ending1 is None:
        $ persistent.ending1 = False
    if persistent.ending2 is None:
        $ persistent.ending2 = False
    if persistent.ending3 is None:
        $ persistent.ending3 = False
Otherwise, you can treat them like any other variable. To flag:

Code: Select all

label ending1:
    "You got the first ending!"
    $ persistent.ending1 = True
To check:

Code: Select all

label check_endings:
    if persistent.ending1 and persistent.ending2 and persistent.ending3:
        jump route4

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Unlockable Route

#4 Post by Destiny »

Ah, lol
I did read everything, replied accordingly...and totally overread that the question was for persistent data :'D
Well yeah, for persistent data, go like saguaro said
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

Ixica
Newbie
Posts: 2
Joined: Sat Mar 22, 2014 11:39 am
Contact:

Re: Unlockable Route

#5 Post by Ixica »

Ah, thank you both, it works absolutely perfectly.

I didn't know about the "and" bit, that's pretty useful, guess I should be paying more attention where it counts, huh? Haha. Thanks a million.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot]