The Persistent Object on Renpy


I'm... really not back, I got a writers block almost all July and August and everything I had to add was way more that I anticipated. 

BUT, I can talk about something I discovered about the framework while doing the visual novel. 

Do you remember those parts in Undertale in which the characters muse about remembering something you did in another playthrough? Like Toriel remembering your pick for favorite pie? Well, I tried to add something similar to the game and I found a save system they use with an object called Persistent. 

The way to use it is adding to the object persistent a new attribute, and since Python is dynamic is actually quite simple.  You go:

$ persistent.value = "Value to save"

(The $ sign is used on Renpy as a escape system of sorts. Everything after the $ symbol is going to be interpreted as pure Python code, instead of some Renpy formatting)

After you add all the values you need to save, you need to call the function which is going to save this. Which is this one:

$ renpy.save_persistent()

Your save folder should have a new file now, called persistent. 

The cool thing is the persistent file is going to be read always no matter which save you load or if you close the game and then open it. You can even call this variables BEFORE the main menu. By using the reserved label "splashscreen".

There you have it. 

Get User Interface

Leave a comment

Log in with itch.io to leave a comment.