• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Game-Over Reload Problem

S

StuffandThings85

Guest
So I followed Slasher Game's guide on Professional Game Saves, and it works well except for one thing (as it pertains to my code, not that the guide doesn't work). At gameover, my game displays "Press R to restart", which I want to either restart the game if there's no save file, or reload the last checkpoint.

The problem is when a checkpoint is activated, pressing "R" does restart the game to the beginning, but I have to press "R" again to load the checkpoint. I want to press "R" to simply load the checkpoint without having to press it twice. The saving and loading does technically work, but not quite as smoothly as I'd like.

In a nutshell, my load script says:
Code:
if (file_exists("player.sav"))
{
          //*loads file and all properties*
}
else
{
        game_restart();
}
In my player object's step event, I have:
Code:
if (keyboard_check_pressed(ord("R"))) scr_load();
In my object gameover's Step event I have:
Code:
if (keyboard_check_pressed(ord("R"))) game_restart();
The gameover script:
Code:
scr_save_cleanup();
game_restart();
and my room rm_initialize's creation code is just:
Code:
"room_goto_next();"
If I change the "game_restart();" parts to "scr_load();" for the play and game over, nothing happens when I press "R". Or if I change the rm_initialize creation code to "scr_load", the game won't load at all. The only way it seems to work is if I press "R" to restart, then press "R" again to load the checkpoint.
 
B

Becon

Guest
Is your player character destroyed as the game ends? If so...your player objects if (keyboard_check_pressed(ord("R"))) scr_load(); won't be recognized because the player object is missing...so it is defaulting to the object game over and seeing
if (keyboard_check_pressed(ord("R"))) game_restart();

The first press is restarting the game and creating the object player. The second is seeing tht the player exists and using that fact to load from the script.

If it was me, I would put bot events into some controller and just have variables running for each call. Is game over? If yes...is there a checkpoint? If yes load. If no restart.

I hope this helps.
 
Top