Using Full State Save/Load

0 favourites
  • 5 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Has anyone used the full state save/load feature successfully?

    I can't seem to figure out two things.

    1. Check whether a saved game exists. I read that you can use web storage to check, but it does not appear to work.

    2. Clear saved games.

    Do you just have to use web storage instead of the full state load/save?

  • I'm not sure whether or not the savegame system can be accessed by WebStorage. I know that it uses the system, but I don't think it does so in the same way as the WS object. I don't think you can access the keys, for example.

    Checking whether a save game exists is a matter of running the Load game action, which will either load the save game if it's found, or report back that it can't be found. In the latter case, you'd use the On load failed action to tell the player that the game can't be loaded.

    Clearing savegames seems to be a feature that's missing, frankly. I can only suggest that, to create the impression of deleting a savegame, you clear all global variables and WS data, then save over the current savegame at the game's main menu. Either that, or perpetually create new savegame names, and only ever make the last one accessible - although that'd get pretty messy over time.

    Personally, I don't use the savegame system, at least not for my current project. I much prefer to use WebStorage where I can focus on saving exactly the data that I want.

  • The best approach is to store metadata in WebStorage about which save slots are in use. Then to clear savegames just clear the WebStorage keys you've been keeping about which slots are in use.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the replies. I will give it a try and report back.

  • I got it working using Ashley's suggested method.

    I offer 2 save slots in my game. On main menu, there are 4 buttons. 2 to clear each of the save slots. And 1 button for each save slot. Each save slot button has 2 frames. "New Game" and "Continue".

    On the start of the main menu layout, I check web storage to see if the key "save1" and "save2" exist. If it does, the corresponding slot button is changed to "Continue". I have 2 variables, save1Exists and save2Exists. If the web storage key exists the corresponding variable is set to 1.

    When either of the save slot buttons are clicked, the system checks if the corresponding saveExists variable is set to 1. If it is, I have another variable called "savedGame" that is set to the value of the web storage key of "save1" or "save2" depending on which button was clicked. Then I load the game from save slot savedGame. The game is only saved at the main layout.

    If the saveExists variable is not set to 1, I set the web storage key "save1" or "save2" to "myGameName(1 or 2 depending on save slot)". I then set the savedGame variable to this web storage value. Then I load the main layout.

    When the main layout loads, the game is saved to save slot savedGame. This main layout is more of a hub layout for the player to move between doing missions, purchasing upgrades and such.

    There may be a better way to do this but, this worked for me.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)