Running code when when a game is loaded [solved]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
expenseroso
Regular
Posts: 28
Joined: Tue Mar 14, 2017 7:15 pm
Contact:

Running code when when a game is loaded [solved]

#1 Post by expenseroso »

Is there a way to run code when a save is loaded?

My game uses a trigger/event system. To make it simple to add events and allow events to be very versatile I have a dictionary that stores them with the event odds, block name, valid triggers, etc. It occurred to me though that if I add new events in subsequent versions old saves won't have access to any events that are added to the initial event dictionary. If I can run some code on game load I can do something like checking the version number and appending the new events, but I haven't been able to find a way to do this.

edit:

Nevermind, just found the answer while searching for something completely different:

https://www.renpy.org/doc/html/label.ht ... ial-labels

Code: Select all

after_load
If it exists, this label is called when a game is loaded. It can be use to fix data when the game is updated.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot]