It does make sense, since technically we are only changing field and not top-level reference, which is documented as an action which does not cause RenPy to add object to list of saved/restored objects.
I tried to assign class reference around, which is enough to trigger saving for normal variables, but it doesn't seem to work with classes.
Here is an example. If you save at the line marked as save point, completely exit the game, launch it again and load the saved game, you will see added event type disappear: it wasn't saved. Additionally, if you play to the end and the start the game again without quitting, added event type will be there from the beginning.
Note: usage of class attribute instead of instance attributes is intentional.
Code: Select all
init python:
class Event:
types = ["repeating", "onetime"]
@classmethod
def new_event_type(cls, type):
if type not in cls.types:
cls.types.append(type)
label start:
'[Event.types]'
$ Event.new_event_type("timed")
'....'
'Save point: [Event.types]' # Save point
'---[Event.types]---'
return