Hi, I’m trying to use a save load system for a project that has one scene. I need to save things for objects already in the scene as well as newly created objects. This post [Solved] Save/load created objects from a few years ago seemed perfect for my needs but I don’t understand it. I’ve read many other posts and watched many videos but I can’t get it.
I think I’ve got the saving part right but I don’t understand what I’m doing with the loading part. Also, the wording of things has changed since that post, so what may have been obvious then is now confusing (my excuse).
Here are the suggested events from @MrMen [Solved] Save/load created objects - #4 by MrMen from the other post and my interpretation of them.
Save
1-3.
Save the various properties of a group object into a structure variable called Character that has named children.
4. Save the structure variable into an array variable called SaveCharacters. How did it get the [“CharacterArray”] part in it? I thought arrays couldn’t have named children? Is the array ‘blank’, that is it has no children?
5. Save the array variable to a json in the appropriate category of storage
Load, this is where I get really confused
6. Get the json from storage and save it as characters_json - what type of variable is it saved to? Just a text variable?
7. Change the text from the characters-json variable into something readable and save it into a variable called LoadStructure - what type of variable? Structure because it has the word structure in the name? But in the Save sequence it was Structure->Array->Json->Storage which would mean it would be an array?
8.Once again, how did [“CharacterArray”] get there? For every object that had its properties recorded in the LoadStructure variable, now duplicate all those things into another variable called LoadDetails? What type of variable is it? A structure? If so, I assume it has the named children from steps 1-3. But if LoadStructure is a structure then why would we now need another structure?
I’ve tried variations of different variable types where I wasn’t sure and nothing works.
Here are my events. I’m not very confident with debugging profiling stuff but I get this error when the load events are toggled on.
Unable to parse JSON: ItemJsonSyntaxError: Unexpected token I in JSON at position 0
The GDJS_Save thing has the save stuff repeated over and over (I deleted the storage to get a fresh start, so it’s not that.
I’ve also tried it with no conditions like in the example and it didn’t change anything.
Also, I will need to save different sets of info for different objects and for multiple instances of those objects. Does that mean that if I ever get something working that I have to have these steps for each set of objects that has its own set of properties? For example, for many objects, I need name, color and position. For others I need those things plus animation name or width. Could all this info be saved into one structure variable and then at the end I just have different create events? That doesn’t sound like it would work.