Page 1 of 1

Running code when when a game is loaded [solved]

Posted: Fri May 12, 2017 8:59 pm
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.