Persistent Data for Multiple Playthroughs

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
Taylor
Newbie
Posts: 6
Joined: Sun Aug 04, 2013 6:48 pm
Contact:

Persistent Data for Multiple Playthroughs

#1 Post by Taylor » Sun Oct 27, 2013 4:09 am

Essentially, I'm looking for a way to activate a "switch" (I'm using true/false statements) in the first playthrough of my game that will be effect the game the second time it is loaded and played from the main menu.

I want to add in a bonus ending that is only available after all other endings have been found.

I have seen it in practice in the game DeIz, so I know it's possible, I just haven't found any info on it.

Thanks in advance!

User avatar
Sorakun
Regular
Posts: 103
Joined: Sun Oct 20, 2013 10:02 pm
Completed: Techno Titans, Blood Metal Exorcism, Tom Cruiser, Mechadin, UPlay
IRC Nick: Sorakun
Skype: sora.ch4n
Contact:

Re: Persistent Data for Multiple Playthroughs

#2 Post by Sorakun » Sun Oct 27, 2013 6:30 am

There are a lot of ways to do this,

Using true/false statements is one way of doing it,
you could also create a variable that would change its value depending on what ending you finished

There is no correct way of doing it.

Also by your statement it sounds like you have the solution so may i ask what it is exactly that you haven't figured out yet?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Persistent Data for Multiple Playthroughs

#3 Post by xavimat » Sun Oct 27, 2013 8:04 am

You can use persistent variables that remain when the game is closed.
At the end of an ending:

Code: Select all

$ persistent.ending_1 = True
when you want to check:

Code: Select all

if persistent.ending_1:
    jump bonus_content
or if you want to present it when every end has been played:

Code: Select all

if persistent.ending_1 and persistent.ending_2 and ...more endings...:
    jump bonus
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Taylor
Newbie
Posts: 6
Joined: Sun Aug 04, 2013 6:48 pm
Contact:

Re: Persistent Data for Multiple Playthroughs

#4 Post by Taylor » Sun Nov 03, 2013 8:05 pm

That's the method I tried. I keep coming up with this error whenever it reaches the "If" line (114):
File "game\script.rpy", line 114, in script
File "game\script.rpy", line 114, in python
NameError: name 'end01' is not defined
Lines 114-115 are:

Code: Select all

    if end01:
        jump bonus_ending
I have "$ end01 = True" during one of the endings.

It seems like the problem is that once the game reaches the If statement, it has an error because 'end01' isn't defined yet. I can't pre-define it, because then it'd just reset every time a new game started. Is it necessary to name it 'persistent.ending'?
Last edited by Taylor on Sun Nov 03, 2013 8:14 pm, edited 2 times in total.

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Persistent Data for Multiple Playthroughs

#5 Post by Tsapas » Sun Nov 03, 2013 8:10 pm

Yeah, persistent variables need to be declared as such. It should be

Code: Select all

    if persistent.end01:
        jump bonus_ending
and

Code: Select all

$ persistent.end01 = True

Taylor
Newbie
Posts: 6
Joined: Sun Aug 04, 2013 6:48 pm
Contact:

Re: Persistent Data for Multiple Playthroughs

#6 Post by Taylor » Sun Nov 03, 2013 8:15 pm

I just made the edit and everything seems to be working fine now. Thanks!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]