Make an updateable save/load system

Hello! I’ve been trying to make an updateable saving system for about 5 months now, but I’m starting to think this isn’t possible, I’ve tried all of the basics such as

  1. Saving individual variables - not updateable nor robust
  2. Saving a structure with children as all the variables you need - not updateable since the values are not carried over to new variables if you already have saved data
  3. The same as 2, but using a climb to check for a variables existence upon load and if the variable doesn’t exist create a variable with the current climb name & value - works okay, but doesn’t transfer the values of child arrays & structures, which I use very frequently

I would just go for option 1 even though it takes an annoying amount of time, But this doesn’t work when I need to save a structure/array & then add new variables to it, of course I could use the climb on option 3, but I end up having very large nests of data that typically look like this:

  • Main array: “Missions”
  • 10-20 Sub structures with 10-20 variables each containing their data
    If I were to use a climb for every one of these variables, It would take an EXPONENTIAL amount of code, so it wouldn’t really work under any circumstances

Does anyone have any other methods to offer? My current best idea is having a completely separate structure with initial values, using the climb to check for the child variable’s existence, and then moving the variable from the initial values structure to the saved data structure, but I have absolutely no clue how to move a variable.

Can you explain the situation, because it’s unclear what you mean?

If you mean between scenes, use Global variables.

If you mean between games (so close game and open it again) then use storage, JSONify the structure to save and parse it when you load. Here’s a link on how to do that.

If it’s neither of these two, then detail the issue a bit better.

Are you talking about app updates? Your app not gdevelop. Like from v. 1.2 to 1.5? If so, I’m guessing your issue is the structure in storage overwrite the structure in the variable setup section. The old structure in storage might have 20 children but the updated structure might have 25.

If so, I’m guessing the way to handle through this is to have a update scene run first. Compare the version number in storage to the current value in the app. If they match then change to the next scene.

If the versions don’t match then convert the old structure into the new one. Then it would be a matter of adding the updated children through events and save the new structure to storage.

I have no experience with this. IDK if you would update directly to the current version or it would update it incrementally. You can’t assume that the person has been updating the app.

So, do you go from v 1.1 to 1.5 or do you do it in steps. 1.1 to 1.2 then 1.2 to 1.3 etc.

It might not just be adding children. It could be removing children or correcting a spelling error in saved data or reducing a maximum value.