Persistent Array data?

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
demonangelz
Regular
Posts: 51
Joined: Tue Aug 23, 2011 10:19 am
Contact:

Persistent Array data?

#1 Post by demonangelz »

Hi all,
I'm not really getting what's happening but basically, I'm getting array values that I didn't append into the code yet when I load a save data.
This is my code:

init python:
array = [ ]
# The game starts here.
label start:
"this is an array test"
$ array.append("string")
"now array has string [array]" #It prints string,string2,string when I reload the file saved at the dialog line "this is an array test" even though I didn't put string 2 in yet
$ array.append("string2")

So for some reason, when I save the game say like at the dialog line "this is an array test", I'm getting the error where the array will string2 already in there when I get to the line to print the array strings even though I didn't reach that line yet to append 'string2' into the code? Can anyone help me explain what's going on and if there's a way so that when I load the game say at "now array has string [array]" it won't contain string2 in there?

Thanks in advance!
I have returned after a long time away. Working on a small project, hope I'll be able to show it on here soon! =D


User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Persistent Array data?

#3 Post by trooper6 »

Note: default only works with renpy 6.99.4, which is still in pre-release.
So if you aren't using 6.99.4 yet, declare you array inside the start block.

Code: Select all

label start:
    $ array = []
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

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Persistent Array data?

#4 Post by nyaatrap »

trooper6 wrote:Note: default only works with renpy 6.99.4, which is still in pre-release.
Oh I thought it's already released because it's written in the document.

demonangelz
Regular
Posts: 51
Joined: Tue Aug 23, 2011 10:19 am
Contact:

Re: Persistent Array data?

#5 Post by demonangelz »

I declared it in the start block and it's working now, thank you very much! :D
I have returned after a long time away. Working on a small project, hope I'll be able to show it on here soon! =D

Post Reply

Who is online

Users browsing this forum: No registered users