[SOLVED] Help with Persistence & Objects & Lists

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
runs
Regular
Posts: 41
Joined: Mon Nov 28, 2011 12:31 pm
Location: Spain
Contact:

[SOLVED] Help with Persistence & Objects & Lists

#1 Post by runs » Wed Mar 28, 2018 7:47 am

I have the following code in screen & python language:

Code: Select all

screen inventory:
   for friend in me.friendslist:
      if friend.isknown & friend.isfriend:

Code: Select all

def firsthand_create():
   del me.deck[:]
They work OK without persistence, but when I add persistence:

Code: Select all

screen inventory:
   for friend in persistent.me.friendslist:
      if friend.isknown & friend.isfriend:

Code: Select all

def firsthand_create():
     del persistent.me.deck[:]
I get this errors:
AttributeError: 'NoneType' object has no attribute 'isknown'
AttributeError: 'NoneType' object has no attribute 'deck'
friendlist and deck are python Lists.

Any idea?
Last edited by runs on Wed Mar 28, 2018 8:17 am, edited 7 times in total.

User avatar
runs
Regular
Posts: 41
Joined: Mon Nov 28, 2011 12:31 pm
Location: Spain
Contact:

Re: Help with Persistence & Objects & & Lists

#2 Post by runs » Wed Mar 28, 2018 7:49 am

Maybe this could cause those errors?
As persistent data is loaded before init python blocks are run, persistent data should only contain types that are native to python or Ren'Py. Alternatively, classes that are defined in python early blocks can be used, provided those classes can be pickled and implement equality.
But I get only problems with Lists.

User avatar
runs
Regular
Posts: 41
Joined: Mon Nov 28, 2011 12:31 pm
Location: Spain
Contact:

Re: Help with Persistence & Objects & Lists

#3 Post by runs » Wed Mar 28, 2018 8:16 am

I've solved. It was an error on my code.

SORRY.

Post Reply

Who is online

Users browsing this forum: No registered users