So I’m making a survival game, and I absolutely dread the thought of having to make save and load data for every single thing… the animation frame for each sprite, the status of resources, player stats, player coords, enemy coords, inventory items, the list goes on and on… Any ideas for how to make the save/load process SIMPLE?
Structure variables are your best friend. With a structure variable, you can save tons of data under ONE variable. Like this:
In this picture, I can save just the Save
variable, and every other variable gets saved.
Here is an explanation of structure variables if necessary:
Structure variables? Huh?
A variable is like a box that can hold information. A structure variable is like a bigger box that can hold tons of smaller boxes inside, each with their own unique information. This “bigger box” is the parent and the “smaller boxes” are the children. If you save the parent, ALL its children get saved too! Children can also have children (like in my example), and you can have almost infinite children (although that becomes messy).
To access structure variables, name the parent, add a . (period / full stop), and name the child (or grandchild, or great grandchild, etc). Like this:
Save.Level set to 5
Save.Player.Health add 40
EDIT: Check the below video for how to do it with the write / read actions. Thanks Silver Streak!
This also works using scene variables. If you’re like me and have global or object variables, you can have temporary scene variables and set the global / object variables as the scene variables. For example:
condition --> load scene variable "Save" from "save.json"
L-> empty sub event --> global variable "Level" set to "Save.Level"