[SOLVED] List Values disappears after game reloading

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
User avatar
Azunelabs
Newbie
Posts: 6
Joined: Sun Jul 06, 2014 1:22 pm
Projects: KONA PROJECT
Organization: Azune Labs Comm
Contact:

[SOLVED] List Values disappears after game reloading

#1 Post by Azunelabs »

Sorry if my question's looks silly, i'm kinda newbie in Ren'Py.
I have a list where many elements appending during gameplay. For example:

Code: Select all

nvle "blah blah blah, let me present you Megou Satsuki"
$ list1.append('Satsuki')
So I restart the game and gone to other screen that checks if "Satsuki" in list1. Chcecking's return that "Satsuki" is not here.
How can I save list values so that they do not disappear after restarting?

In advance, thanks and sorry for my english :3
Last edited by Azunelabs on Tue Jul 15, 2014 2:29 am, edited 1 time in total.

User avatar
ArachneJericho
Regular
Posts: 196
Joined: Sun Jun 22, 2014 2:04 am
Projects: Kaguya Hime
Tumblr: mousedeerproductions
Location: Seattle, WA, USA
Contact:

Re: List Values disappears after game reloading

#2 Post by ArachneJericho »

Where did you create your list? You shouldn't create it in an init, you need to create it under a label (like the start label).

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: List Values disappears after game reloading

#3 Post by Asceai »

I'm not certain that's the issue, as loading a saved game was never mentioned in the post. Sounds more like you want Persistent Data.

User avatar
Azunelabs
Newbie
Posts: 6
Joined: Sun Jul 06, 2014 1:22 pm
Projects: KONA PROJECT
Organization: Azune Labs Comm
Contact:

Re: List Values disappears after game reloading

#4 Post by Azunelabs »

Oh guys, thanks, but for some reason, it's not working on me :(
Maybe it will be more understandful on pic?
Attachments
32.png

nintendotoad
Regular
Posts: 42
Joined: Sat Mar 31, 2012 2:56 pm
Location: projectexist.net
Contact:

Re: List Values disappears after game reloading

#5 Post by nintendotoad »

Oh I see. Asceai was indeed correct, you do want persistent data. Persistent data "stays the same" through the game (even if you do not save) unless you manually change it. That means you'll want to do this:

Code: Select all

init -1 python hide:
    # Check if list1 exists! If it doesn't, make it!
    if persistent.list1 is None:
        persistent.list1 = []
Now if you do $ persistent.list1.append("Satsuki"), Satsuki will be added to that table.
This brings up another problem though. What happens if the game gets played twice? Or three times?

Code: Select all

$ persistent.list1.append("Satsuki")
$ persistent.list1.append("Satsuki")#uh-oh...
$ persistent.list1.append("Satsuki")#OH GOD NO
#oh no, "Satsuki" is in the list three times!
So before having the game happily add "Satsuki" to the list...

Code: Select all

if "Satsuki" not in persistent.list1:
    $ persistent.list1.append("Satsuki")#yay, unlocked!
You can see this in action in the attached demo script.
Attachments
script.rpy
(524 Bytes) Downloaded 51 times

User avatar
Azunelabs
Newbie
Posts: 6
Joined: Sun Jul 06, 2014 1:22 pm
Projects: KONA PROJECT
Organization: Azune Labs Comm
Contact:

Re: List Values disappears after game reloading

#6 Post by Azunelabs »

Oh, thank you all! :D Sorry that I can not please you finished novel, because it, unfortunately, written in Russian.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Sugar_and_rice