Legacy GM game_save() and game_load() going to different places

Hey everybody,

I'm using the in-game save and load features and get_save_filename() to get the path.

The game saves as the player advances and when you quit you can load back where you were. Great!

But then after you resume, the game isn't saving properly. I got especially confused and frustrated when I have this code:
Code:
game_save(global.game_name)
game_load(global.game_name)
The game apparently saves and it should load the same file immediately after but it loads the old save file instead.

Any ideas on why this is happening?

Additional notes: The save file isn't updating the second time around. I tried putting a delay between saving and loading and still had the same results.
 

TsukaYuriko

☄️
Forum Staff
Moderator
When you're manually bypassing the sandboxing, make sure that you realize that permission will only be granted until you close the game. Loading the game may or may not clear the permission as well - I'm not sure about that, but that's easy to test for yourself.

I suggest saving to the default location and sticking to the sandboxing so that finding the correct path can be handled at the engine level without your intervention being required.
 
Last edited:
I

icuurd12b42

Guest
permission for saving outside the sandbox is given by get_save_filename()
permission for loading outside the sandbox is given by get_open_filename()
 

TsukaYuriko

☄️
Forum Staff
Moderator
permission for saving outside the sandbox is given by get_save_filename()
permission for loading outside the sandbox is given by get_open_filename()
No, they both grant both permissions.
http://docs.yoyogames.com/source/dadiospice/002_reference/file%20handling/file%20system/get_save_filename.html said:
An important thing to note when using this function is that it grants you certain permissions for that file, for the duration of your game. So, once you get the file path from the user, you can access it again and again without having to ask, and the permission applies to reading and writing equally.
 
Last edited:
When you're manually bypassing the sandboxing, make sure that you realize that permission will only be granted until you close the game. Loading the game may or may not clear the permission as well - I'm not sure about that, but that's easy to test for yourself.

I suggest saving to the default location and sticking to the sandboxing so the finding the correct path can be handled at the engine level without your intervention being required.
So are you saying not to use get_save_filename() and just use the AppData folder? I wanted to use get_save_filename() because game_load() opens in my documents and game_save() opens in the working directory.

I really can't figure out why

game_save(global.game_name)
game_load(global.game_name)

saves and loads at 2 different places
 

TsukaYuriko

☄️
Forum Staff
Moderator
So are you saying not to use get_save_filename() and just use the AppData folder? I wanted to use get_save_filename() because game_load() opens in my documents and game_save() opens in the working directory.

I really can't figure out why

game_save(global.game_name)
game_load(global.game_name)

saves and loads at 2 different places
Correct. If these two functions aren't resolving their paths correctly (do keep in mind that reading has two valid source locations as defined by the sandbox - but local storage is prioritized over the game bundle, so this shouldn't cause issues), then something else must be interfering with the pathfinding, such as usage of the single runtime executable export or other forms of exe compressors, just to name one of the primary culprits.

I'm not sure how you're figuring out which paths these two functions read from / write to, though... because that's a black-box process as far as I'm aware, excluding the File System Limits manual page's listing of standard resolve paths. Is there a special trick to this that I'm missing? Or are you potentially checking this in a way that doesn't work the way you think, thus leading to these unexpected results?
 
I used get_save_filename() and saved the result as a global variable. Then I just keep using that variable. I write it on the screen to make sure it's the right path and it is: the one leading to my documents. When I use the variable to save and load it includes the file path and normally goes to the right place. Unless I exit and resume. Then it reads from the right place but writes to the wrong one.

I'm checking out the saving/loading tutorial now. Maybe it will help
 
Top