How to check if save file exists/has all needed variables? #2801
Answered
by
Geokureli
NikRetaNCAM
asked this question in
Q&A
-
My game uses multiple save files (3), override public function create(){
saves = [save1, save2, save3];
save1.bind("save1");
save2.bind("save2");
save3.bind("save3");
} They seem to work fine BUT in order for them to do that you need to manually reset the save function resetSave()
{
saves[curSave].data.location = 'hub';
saves[curSave].data.level = 0;
saves[curSave].data.cardLv = 0;
saves[curSave].data.money = 0;
// MONEY 1, MONEY 2, MONEY 3, SECRET, TIME, DEATHS, RANK
var lvlInfo:Map<String, Array<Dynamic>> = ["tut" => [false, false, false, false, null, null, null]];
saves[curSave].data.lvlInfo = lvlInfo;
saves[curSave].flush();
} otherwise the game will crash |
Beta Was this translation helpful? Give feedback.
Answered by
Geokureli
May 16, 2023
Replies: 1 comment 3 replies
-
I just null check properties in the save data, if they are null the save must not exist |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no, i check if a specific var is null, and if it is, I know there is no save and set up the default save, or call resetSave in your case. for instance you can check for
saves[curSave].data.location == null
or something