Page 1 of 1

Unlockable Route

Posted: Sat Mar 22, 2014 11:52 am
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.

Re: Unlockable Route

Posted: Sat Mar 22, 2014 7:52 pm
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).

Re: Unlockable Route

Posted: Sat Mar 22, 2014 9:39 pm
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

Re: Unlockable Route

Posted: Sat Mar 22, 2014 9:52 pm
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

Re: Unlockable Route

Posted: Sun Mar 23, 2014 3:18 pm
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.