How to set up persistent data within a RevertableSet
Posted: Sat Mar 19, 2022 2:55 pm
Hi guys
I've been struggling for a while trying to figure out the best way to do this thing but now I'm stuck and need some advice.
My game includes three characters, each has their own good ending (and bad ending). I need to set up a persistent variable for when an ending is achieved so it knows who's route they've successfully completed.
Currently I'm using the RevertableSet persistent method which I think suits best. I set my persistent up as follows (the names in the object being the names of the characters whose ending you can achieve):
Then I register the persistent with the following function:
When I want to set it, I use:
But if I do a check on any of the others to see if they are True, I get an error saying that it doesn't exist. Basically I need to know how I'm able to do a check on the other endings, something along the lines of 'does this variable exist in the current set' but, in code obviously. Because if I simply put:
Then it just tells me that 'rose' does not exist in the RevertableSet() 'seen_endings' even though I have set that right at the beginning - unless I'm missing something? Any help on this is much appreciated.
Thanks
Michael
I've been struggling for a while trying to figure out the best way to do this thing but now I'm stuck and need some advice.
My game includes three characters, each has their own good ending (and bad ending). I need to set up a persistent variable for when an ending is achieved so it knows who's route they've successfully completed.
Currently I'm using the RevertableSet persistent method which I think suits best. I set my persistent up as follows (the names in the object being the names of the characters whose ending you can achieve):
Code: Select all
if persistent.seen_ending is None:
persistent.seen_ending = set({'lily','rose','iris'})Code: Select all
def merge_endings(old, new, current):
current.update(old)
current.update(new)
return current
renpy.register_persistent('seen_ending', merge_endings)Code: Select all
$ persistent.seen_ending.lily = TrueCode: Select all
if persistent.seen_endings.rose:
// do something hereThanks
Michael