[solved] Persistent 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
User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

[solved] Persistent Data

#1 Post by Kaen »

I'm using persistent data to store several values on my game.

On my computer the code using persistent data works fine but when I distribute the game and play it on another computer I get an error 'NoneType' object has not attribute '__getitem__'.

It seems the persistent data is not being initialized or something...?

Any tips?
Last edited by Kaen on Sat Aug 16, 2014 6:54 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Persistent Data

#2 Post by Alex »

Looks like, you need to set the default value for this kind of variable before checking or using its value (like for normal variable). Should look like

Code: Select all

init:
    if not persistent.my_var:
        $ persistent.my_var = some_value
In this case the default value will be set only if no value was set at all.

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Persistent Data

#3 Post by Kaen »

Humm thank you Alex I'll try that.

@edit
The sugestion resolved the problem!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]