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.
Unlockable Route
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.
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.
- Destiny
- Veteran
- Posts: 468
- Joined: Thu Jun 14, 2012 2:00 pm
- Projects: Cards of Destiny, Sky Eye
- Location: Germany
- Contact:
Re: Unlockable Route
It's quite simple: use statements
Create three statements at the veeeeeeeery beginning of script.rpy under init and set them to false:
Then, upon archieving the end of a route, set
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:
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:
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.
This way, you get a positive response as long as ONE of the listed ones is active (in case, that is relevant).
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
Code: Select all
$ A_done = True
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
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
Alternatively: if ANY ending will do, use a colon.
Code: Select all
if A_done, B_done, C_done:
e "Good work!"
return
Cards of Destiny (WIP) / Sky Eye (WIP)
- 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
For persistent variables, you'll want to set up something like this in an init block.
Otherwise, you can treat them like any other variable. To flag:
To check:
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
Code: Select all
label ending1:
"You got the first ending!"
$ persistent.ending1 = True
Code: Select all
label check_endings:
if persistent.ending1 and persistent.ending2 and persistent.ending3:
jump route4
- Destiny
- Veteran
- Posts: 468
- Joined: Thu Jun 14, 2012 2:00 pm
- Projects: Cards of Destiny, Sky Eye
- Location: Germany
- Contact:
Re: Unlockable Route
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
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
Cards of Destiny (WIP) / Sky Eye (WIP)
Re: Unlockable Route
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.
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.
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot]