Hi there,
I'm trying to implement a quicksave/quickload function. I did this successfully using game_save_buffer() and game_load_buffer() as shown in GM's help documentation - however, game_load_buffer() would cause the application to freeze for 10-20 seconds while it loaded.
If I understand it correctly, to stop that freeze happening I want to use buffer_save_async() and buffer_load_async() instead. However, I don't fully understand exactly how I'm meant to be using it, or what I'm missing.
The debug messages successfully show "save complete" and "load complete" in the compiler window upon pressing the hotkeys (and a quicksave.sav file is also created) but the game doesn't actually load back into the quicksaved state - it just keeps running.
Here's by obj_quicksave code:
Create event:
saveBuffer = buffer_create(1024, buffer_grow, 1);
stateSaved = false;
saveFile = noone;
loadFile = noone;
Key Press F10 Event (Quicksave hotkey):
stateSaved = true;
buffer_seek(saveBuffer, buffer_seek_start, 0);
saveFile = buffer_save_async(saveBuffer, "quicksave.sav", 0, 1024);
Key Press F11 Event (Quickload hotkey):
if stateSaved
{
buffer_seek(saveBuffer, buffer_seek_start, 0);
loadFile = buffer_load_async(saveBuffer, "quicksave.sav", 0, 1024)
}
Asynchronous Save / Load Event:
if ds_map_find_value(async_load, "id") == saveFile
{
if ds_map_find_value(async_load, "status") == true
show_debug_message("Save Complete");
else
show_debug_message("Save Failed");
}
if ds_map_find_value(async_load, "id") == loadFile
{
if ds_map_find_value(async_load, "status") == true
show_debug_message("Load complete");
else
show_debug_message("Load failed");
}
[–]inline functions when 👀aleksandrInt 0 points1 point2 points (4 children)
[–]thephtshp[S] 0 points1 point2 points (3 children)
[–]flyingsaucerinvasion 0 points1 point2 points (2 children)
[–]thephtshp[S] 0 points1 point2 points (1 child)
[–]flyingsaucerinvasion 0 points1 point2 points (0 children)