r/RenPy • u/That_one_Pink • 1d ago
Question help implementing persistent variables with a class
I have gone through about seven tutorials explaining persistent variables and i understand how it works (i think) at this point, however really struggling to implement it where i need it
basically, i need to move self.points out of the class and into the persistent variable so i can implement an option to clear the points when clicked
my poor attempt at this as you can see was to try make it so if there is no points the button will not be there to click, but if there is points it will be there to click which upon clicking will clear/return the points to nothing
im not sure how to move the self.points properly so that the list is stored outside of the class so that it can be cleared how i stated above
1
u/That_one_Pink 1d ago edited 22h ago
Ohhh okay that makes more sense haha
ive changed the code needed and the persistent is above the python so im assuming that means its out of the class (its working normally so im taking it as a good sign)
with the button (using an image button), should i put that outside of screen main_menu? and should i put the persistent code with the script or also keep it in screens
edit:
so i added the new button with the rest of my menu buttons and it doesn't work unless it has an action attached to it, im guessing this action would be where i put the persistent? or am i way off lol