How to revert a save state if the player dies before saving?

Discussion and help for Easy Save 3
Post Reply
MBS_88
Posts: 4
Joined: Fri Jul 01, 2022 6:23 am

How to revert a save state if the player dies before saving?

Post by MBS_88 »

Hello all!

I could really use some help conceptualizing how to do this...

Essentially, I currently have doors and other objects saving their state as soon as the 'open' so that when re-entering the room they remain open.
However, if the player dies before reaching a save station, I would like these things to revert back..

How would i do this with Easy Save?

Thank you so much for your help
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to revert a save state if the player dies before saving?

Post by Joel »

Hi there,

To revert back you would usually use SceneManager.LoadScene to reload the scene. However, if you wanted to do this without reloading the scene, you would need to save everything at the very beginning before the player does anything to a separate save file and load this when you want everything to reset.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
MBS_88
Posts: 4
Joined: Fri Jul 01, 2022 6:23 am

Re: How to revert a save state if the player dies before saving?

Post by MBS_88 »

Joel wrote: Fri Jul 01, 2022 7:57 am Hi there,

To revert back you would usually use SceneManager.LoadScene to reload the scene. However, if you wanted to do this without reloading the scene, you would need to save everything at the very beginning before the player does anything to a separate save file and load this when you want everything to reset.

All the best,
Joel
Thank you so much for the response Joel!

I may have not been accurate enough with my description :) apologies!

Currently, I have it that there are certain doors and items that are locked in a room, and once opened/obtained, IMMEDIATELY SAVEs a bool to the save file. This is so that during the same play session, if the player moves to another scene and comes back the doors remain open. HOWEVER!
I am struggling with how to make it so that these doors stay open during the game, but if the player dies before reaching a SAVE STATION to lock in their progress, all the new save data reverts back to before (the last time they saved).

Thank you again for your quick response, it is incredibly appreciated!
Cheers my friend!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to revert a save state if the player dies before saving?

Post by Joel »

Hi there,

Thanks for the clarification. Is there any reason you’re not saving the state of all of the doors when they hit the save station, rather than save the state of each individual door when it’s interacted with?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
MBS_88
Posts: 4
Joined: Fri Jul 01, 2022 6:23 am

Re: How to revert a save state if the player dies before saving?

Post by MBS_88 »

Hey Joel!

Yea, so I save the state of the door at the moment of 'Unlock' because when the player exits the room and then returns, I need the locked door to remain open.

Problem being, that if the player 'dies' before saving this progress, I would like the state to revert...

My idea as of now is to like... figure out a way to write a script to logs all data that can be reverted... and only lock it in at a save station?? I really don't know what the best practice for this scenario would be :(

Thanks again for your help! Looking forward to hearing from you so I can continue progress :D

Cheers!
MBS_88
Posts: 4
Joined: Fri Jul 01, 2022 6:23 am

Re: How to revert a save state if the player dies before saving?

Post by MBS_88 »

Joel wrote: Mon Jul 04, 2022 10:03 am Hi there,

Thanks for the clarification. Is there any reason you’re not saving the state of all of the doors when they hit the save station, rather than save the state of each individual door when it’s interacted with?

All the best,
Joel
Hey Joel!

Yea, so I save the state of the door at the moment of 'Unlock' because when the player exits the room and then returns, I need the locked door to remain open.

Problem being, that if the player 'dies' before saving this progress, I would like the state to revert...

My idea as of now is to like... figure out a way to write a script to logs all data that can be reverted... and only lock it in at a save station?? I really don't know what the best practice for this scenario would be :(

Thanks again for your help! Looking forward to hearing from you so I can continue progress :D

Cheers!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to revert a save state if the player dies before saving?

Post by Joel »

Hi there,

In this case you would need a save file for each room, and keep a List of all rooms which have not yet been saved.

When the player dies, delete the save file for each room which has not been saved using ES3.DeleteFile.

When the player enters the save station, clear the List of all rooms which have not yet been saved.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply