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.
-
Kinmoku
- Miko-Class Veteran
- Posts: 560
- Joined: Mon Aug 11, 2014 9:39 am
- Completed: One Night Stand
- Projects: Love IRL, Memories
- Tumblr: gamesbykinmoku
- itch: kinmoku
- Location: Germany
-
Contact:
#1
Post
by Kinmoku » Fri Jul 29, 2016 10:59 am
Hi guys,
I'm not a very good coder and I'm trying to understand more about permanent game data, such as variables which will stay there even when you restart the game and play again.
At the start, I have the following code:
Code: Select all
label start:
default arrives = False
$ found = []
So each time the game starts up, the majority of variables reset and the game starts a new.
However, I want to create some variables which stay permanent no matter how many times you play and I've never done that before...
I want to create another list called $ endings_unlocked = [] but I'm unsure where to put it. I'd the endings unlocked to stay permanently and only be removed if you delete/ uninstall the game. How do I do this?
Last edited by
Kinmoku on Fri Jul 29, 2016 12:24 pm, edited 1 time in total.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#2
Post
by trooper6 » Fri Jul 29, 2016 11:41 am
Kinmoku wrote:Hi guys,
I'm not a very good coder and I'm trying to understand more about permanent game data, such as variables which will stay there even when you restart the game and play again.
At the start, I have the following code:
Code: Select all
label start:
default arrives = False
$ found = []
So each time the game starts up, the majority of variables reset and the game starts a new.
However, I want to create some variables which stay permanent no matter how many times you play and I've never done that before...
I want to create another list called $ endings_unlocked = [] but I'm unsure where to put it. I'd the endings unlocked to stay permanently and only be removed if you delete/ uninstall the game. How do I do this?
So first off, let's look at the code you provided.
Before your game starts (in other words, before the start label, not in the start label) is when you declare your variables. So you should have this instead:
Code: Select all
default arrives = False
default found = []
label start:
"Blah blah blah"
Next, if you want to have a variable that lasts between games, you want persistent variables.
Here is the documentation of persistent variables:
https://www.renpy.org/doc/html/persistent.html
However, here is the newer update on how to define persistent variables:
https://www.renpy.org/doc/html/changelo ... provements
This would look like this:
Code: Select all
default arrives = False
default found = []
define persistent.endings_unlocked = [ ]
label start:
"Blah blah blah"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
Kinmoku
- Miko-Class Veteran
- Posts: 560
- Joined: Mon Aug 11, 2014 9:39 am
- Completed: One Night Stand
- Projects: Love IRL, Memories
- Tumblr: gamesbykinmoku
- itch: kinmoku
- Location: Germany
-
Contact:
#4
Post
by Kinmoku » Fri Jul 29, 2016 12:22 pm
trooper6 wrote:Before your game starts (in other words, before the start label, not in the start label) is when you declare your variables. So you should have this instead:
Code: Select all
default arrives = False
default found = []
label start:
"Blah blah blah"
Next, if you want to have a variable that lasts between games, you want persistent variables.
Here is the documentation of persistent variables:
https://www.renpy.org/doc/html/persistent.html
However, here is the newer update on how to define persistent variables:
https://www.renpy.org/doc/html/changelo ... provements
This would look like this:
Code: Select all
default arrives = False
default found = []
define persistent.endings_unlocked = [ ]
label start:
"Blah blah blah"
Oh thank you, this is a great help! I've always put the variables under start for some reason

Thanks for the advice!
Ahhh, so I'd been searching for "permanent" and nothing showed up XD These links all look super useful though, so thank you for sharing!
