Using saveVars and loadVars has been explained very many times on this forum.
You should try to find out by yourself before asking questions, because there really is answers to most of the simpler questions people have.
I'll explain it to you now shortly.
You know what variables are, right?
So, for saving the player actors position (values of x and y), you have to first create two global integer variables with a save group.
You can name the save group whatever you want, an example would be playerPosition.
Then, you write this code to the script editor event where you want to save the game:
- Code: Select all
posX = player.x;
posY = player.y;
saveVars("gamesaves.sav", "playerPosition");
The position will be saved to a file named gamesaves.sav.
This code is all you need for saving the player position provided that your variables are named posX and posY, and that they belong to a save group named playerPosition, and that your main actor is called player.
Then when you want to load the values, and set the player actor back to the saved position, you just have to write this:
- Code: Select all
loadVars("gamesaves.sav", "playerPosition");
player.x = posX;
player.y = posY;
This is all you need for saving and loading an actors coordinates.
I hope that you think through the code, because just copying it to your game won't help you learn anything, because learning code is possible only after understanding it.
If you don't understand the code, say it, and I'll explain it to you bit by bit so that you will understand and learn it.