Okay, so far so good. Now, the Event class has a property with a lambda function assigned to it to allow for custom per-event logic about when the Event can occur. This should be fine. Lambdas are not pickleable and can't be saved in a game save, but Events aren't supposed to be saved at all so this shouldn't matter.
However. Ren'py keeps trying to save one or more Events, and then bitching at me that they can't be saved because "PicklingError: Can't pickle <type 'function'>". The traceback doesn't seem to give me any information about *which* Event is trying to be saved, so I don't know if it's all of them or one in particular. I have read over my code, and I can't see anywhere where an Event instance is assigned to a variable that I think is supposed to be saved.
* Is there some way to read exactly what's in the save file, so I can maybe figure out what's in there that isn't supposed to be?
* Is there any way to declare that certain objects are *never* supposed to be saved?
* Is there documentation somewhere that lays out precisely what is and is not eligible for saving?
My understanding is that variables that are only assigned to in init blocks are *not* saved, and that variables that are local to python functions and methods are also *not* saved.
For clarity, this is some stripped down code to give an idea of what I'm doing:
Code: Select all
define all_quests=[]
init python:
class Quest(object):
def __init__(self):
self.events = []
def add_event(self, ev):
ev.quest = self
self.events.append(ev)
class Event(object):
def __init__(self, condition=None):
self.condition = condition if condition else (lambda x: True)
def can_happen(self):
return self.condition(clock)
q = Quest()
q.add_event(Event(condition = (lambda x: x>10)))
q.add_event(Event(condition = (lambda x: x>20)))
q.add_event(Event(condition = (lambda x: x==32)))
all_quests.append(q)