How do I Detect Save Games without loading entire Save State

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.
  • Hi guys,

    Hopefully this makes sense. I have three save slots for my game. If the player wants to load a save game, I'd like for them to go the load game/continue screen and see the progress of each saved game (i.e. current level, lives, etc.) The way I have this set up is when the player saves the game, that slot has a flag set that lets the game know that slot has save data.

    On the continue screen, if the player goes to that save slot and the corresponding flag is set, the save data shows.

    Here's the problem: I need to save only those three save slot flags when the game starts. I'm not sure how to achieve this.

    Any help is appreciated.

  • Hey man,

    where exactly do you want to save those flags to at the start of the game?

    To global or local variables?

    And how are those flags stored in general? Are they stored via the LocalStorage object? Or in a variable?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey man,

    where exactly do you want to save those flags to at the start of the game?

    To global or local variables?

    And how are those flags stored in general? Are they stored via the LocalStorage object? Or in a variable?

    Hey, sorry for the late response.

    I'm using global variables for the for the save flags and save data (for example):

    HasSaveData_Slot1 (Bool, "false" by default)

    CurrentLives_Slot1 (Int)

    CurrentWorld_Slot1 (Int)

    When the player saves the game to slot 1 using the build-in save feature, HasSaveData_Slot1 is set to true and sets CurrentLives_Slot1 and CurrentWorld_Slot1 accordingly.

    When the player goes to the continue screen, if slot1 is highlighted, if HasSaveData_Slot1 is true, then it displays the values of CurrentLives_Slot1 and CurrentWorld_Slot1; else it shows there is no save data.

    I just want to load the last values for HasSaveData_Slot1,CurrentLives_Slot1 and CurrentWorld_Slot1 when the game starts up. So, could I achieve that through local storage?

  • So what you basically want to do, is to load up those values for the last used slot?

    At the end of a game (e.g. when the player closes the game) you want those values to be saved and loaded up when the game starts the next time, right?

    Sorry, I still need to grasp what your plan is here. ;)

    If that is your idea, then what you need to do is:

    • add the Local Storage object to your project
    • at the point where you want to save the values to the Local Storage, add an action for Local Storage, by the name of Set item.

    Now you can choose a key name and the value for that key.

    You could either just go with one key and format your three values as a simple string which you would have to parse on the start of the game. [This could look like this:

    Set item "slot1" to: "#1" & HasSaveData_Slot1 & "#2" & CurrentLives_Slot1 & "#3" & CurrentWorld_Slot1[/code:3a4suqmx]At the start of the next game, you would then get the item "slot1" and parse the string via some system expressions ("find", "mid",...)]
    
    [b]Or you could simply[/b] go with three [i]set item[/i] actions to save each variable as an individual key.
    This would look like this:
    [code:3a4suqmx]Set item "HasSaveData_Slot1" to: HasSaveData_Slot1
    Set item "CurrentLives_Slot1" to: CurrentLives_Slot1
    Set item "CurrentWorld_Slot1" to: CurrentWorld_Slot1[/code:3a4suqmx]
    
    [b]No matter which option you choose:[/b]
    At the start of the game, you would go with an action[code:3a4suqmx]Check item "itemname" exists[/code:3a4suqmx]
    (replace "itemname" with either "slot1" or "HasSaveData_Slot1", .... depending on which option you chose previously)
    Followed by an event [code:3a4suqmx]On item "itemname" exists[/code:3a4suqmx]containing the action [code:3a4suqmx]Get item "itemname"[/code:3a4suqmx]
    You would then follow this again by an event[code:3a4suqmx]On item "itemname" get[/code:3a4suqmx] containing actions which either
    a) parse the single key "slot1" to apply them to the variables in the project
    or
    b) apply each of the three keys "HasSaveData_Slot1",... to the corresponding variables.
    
    That would be it.
    This sounds more complicated than it is and I would really like to assist you with images, but I can't do this atm.
    Of course, these instructions only apply if I understood your explanations correctly.
    
    I hope, I didn't explain the whole process to you when you already knew it and were asking for sth. completely different.
    Let's just hope I could help you somehow. :)
  • Thanks so much for the help Randomly. I think I got it...almost!

    Here's my save screen's event. I am creating a local storage key to hold each value I want to save (too lazy to parse out a string).

    Here's the event sat the start of the game where all the local storage values are retrieved and set to the global variables. I don't think this is correct though, because when I go to view my saved game info, it shows no save data exist (meaning it's not correctly pulling data from the local storage and setting those values to my variables.)

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