How do I Detect Save Games without loading entire Save State

Get help using Construct 2

Post » Fri Sep 30, 2016 10:55 pm

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.

Image
B
9
S
1
Posts: 24
Reputation: 513

Post » Sat Oct 01, 2016 4:06 pm

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?
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sun Oct 02, 2016 5:01 pm

randomly wrote: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?
B
9
S
1
Posts: 24
Reputation: 513

Post » Sun Oct 02, 2016 6:09 pm

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:
Code: Select all
Set item "slot1" to: "#1" & HasSaveData_Slot1 & "#2" & CurrentLives_Slot1 & "#3" & CurrentWorld_Slot1
At the start of the next game, you would then get the item "slot1" and parse the string via some system expressions ("find", "mid",...)]

Or you could simply go with three set item actions to save each variable as an individual key.
This would look like this:
Code: Select all
Set item "HasSaveData_Slot1" to: HasSaveData_Slot1
Set item "CurrentLives_Slot1" to: CurrentLives_Slot1
Set item "CurrentWorld_Slot1" to: CurrentWorld_Slot1


No matter which option you choose:
At the start of the game, you would go with an action
Code: Select all
Check item "itemname" exists

(replace "itemname" with either "slot1" or "HasSaveData_Slot1", .... depending on which option you chose previously)
Followed by an event
Code: Select all
On item "itemname" exists
containing the action
Code: Select all
Get item "itemname"

You would then follow this again by an event
Code: Select all
On item "itemname" get
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. :)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Tue Oct 04, 2016 4:40 pm

Thanks so much for the help Randomly. I think I got it...almost!

Image
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).

Image
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.)
B
9
S
1
Posts: 24
Reputation: 513


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, Lordshiva1948, OBLIVION and 18 guests