How do you make a Save and Load System for a Top-Down Game
Basically it saves your position in the Map and that’s all
I just need a bit of help figuring out how to do something like that and to where you can load it with a button with loads the file and when you save it, it saves the file in your files app (like on Mobile or Desktop) and you can load it back up
Please Help
I may not be the most helpful guy, but here is a link to the documentation for storage.
You can use storage events to save and load stuff easily without worrying about files.
Yes, It will not reset when you close the game, unless you have android device, in which, you could clear the game data using the settings of android.
This is JUST save load variable (which is actually how we save stuff in our games)
So if you set your player position to some var
Then save it to storage
Then when game is open again load storage
AND THEN set position to variable that was loaded from storage
You will get what you want
In bottom of that post i do that to music
Do the Storage Events work for the Checkpoint Extension as well?
Probably No.
You should manually save the checkpoint position.
Can You explain this a bit more so its easier for me to understand?
Actually instead of explaining it
I will give you chance to experience it 1st hand
Make global variable and set it to structure and literally name it MySave
Now add child variable to that structure actually add 2
Name on XPos and other YPos and both should be number variables
Now you reference these variables by MySave.XPos and MySave.YPos
So as you see you 1st write name of your structure which is MySave
Then follow that with dot . to indicate left from dot is structure parent var
And next you give name of your child var so either XPos or YPos
Again MySave.XPos
And magic of that is you DO NOT save MySave.XPos and MySave.YPos variables
Nah you only perform save to MySave
And by now you should realize it works like throwing files into ONE folder
And now you move only that folder and all its sub folders will move with it
And yeah that is exactly what structure variables are
FOLDERS for other variables
Armed with that knowledge
All you need to do now in your project is event that if you for example press S key you set MySave.XPos to Player.X() and MySave.YPos to Player.Y()
So you stored X and Y pos of your player to these 2 child vars of MySave structure
Now you go to my post with how to save/load
And you prepare replicate saving to storage and loading from storage
BUT with some key press
For example Q key to save and E key to load
You will most likely fail
I failed 3 times before i got it right and that is because we all add “” everywhere or that we don’t or we mix where storage name should go with group name
So don’t worry if it won’t work 1st time
Anyway after you done that
There is one final step
AFTER you load from storage
Right under it make event to change player X position to MySave.XPos and player Y position to MySave.YPos
You see saving/loading to and from storage only does that
Save some informations or load them from storage
Kinda like you would take a picture of your password to your forum account
Cool you made screenshot now show it to your monitor and what? It will log you in?
Nah you need to input these characters yourself
Same story here
You saved some information you need now to load them and now change something to reflect these infomations
In other words you loaded some values to variables
And now you can set something to have same values as these variables
In this case its just 2 position one for X and other for Y
If you care for more in depth explanation i am kinda expert here in creating walls of text as you see
So be careful what you ask for
BTW after you perform save
You can close your game open it again then perform load and it will still work
AND
If you care for checkpoints extension
Look what i explained to you above
Imagine what would happen if you set MySave.XPos and MySave.YPos
To player position whenever your player is in collision with any checkpoint?
which Post is the How To Save/Load?
I told you
It is ultra rare for someone to get it right in 1st attempt
I personally saw it only few times and i explained save/load logic to A LOT of users
I could literally count lucky ones that did manage to pull it off in 1st attempt on fingers of my ONE hand
And that is after i would cut off 2 fingers from it
Anyway there are 2 things
Error itself
And logic problem
1st let’s go with error
MIne
Yours
As you see you miss one action there
Convert JSON string
And you storing in your action info from storage into MySave variable
Instead of temp variable which is scene variable
After you fix that
You only miss some logic
Most important thing you NEED trigger once in condition
Now here
Above this save action
You need 2 actions
Change variable MySave.XPos set to Player.X()
Change variable MySave.YPos set to Player.Y()
Because 1st you change variables to position of player
And after that you perform a save
Next AGAIN
You absolutely need here trigger once in condition
Then you add sub event
In which you add action
Change player position X set to MySave.XPos Y set to MySave.YPos
And now your saving and loading will work
Because you 1st load from storage which gives your variable values
And after that you can use these variables for something
Like for example changing player position
Events are now ok
You just don’t set variable to anything before save
And don’t change player pos to variable after load