For a project I'm working with I want to make sure that save files from old versions can be loaded by new versions.
Since the format in which data is stored may change, I'd like to setup a function that can modify save data after it has been loaded.
To give a basic example, let's say in version 1 an integer value is stored directly in "store.someVar" however in version 2 it gets stored in a wrapper class.
So upon loading a save I'd like something like this to run:
Code: Select all
if store.version == 1:
store.someVar = Wrapper(store.someVar)
And from what I understand from looking at the source, these "states" are chained together and just store how data got changed between them.
So if upon loading a file I want my update code to run on *all* saved states, how would I do that?
(Running the update code everytime a rollback occurs is also an option, but I'd prefer it if it only happens when a file is loaded)
Thanks