This is a follow-up question to this
I started using the localStorage function, and am unsure whether or not its working as intended.
I want to overwrite a boolean in my JSON file.
Player hits an exit in a stage, then it triggers the load of the next stage, but I also want it to save the fact that the stage was completed.
Here is my JSON array, defining that all dungeons are incomplete by default:
var dungeon_prog = {
"dungeon0_prog" : {
"complete" : true
},
"dungeon1_prog" : {
"complete" : false
},
"dungeon2_prog" : {
"complete" : false
}
};
Then I set it to local storage:
localStorage.setItem('dungeon_prog', JSON.stringify(dungeon_prog));
var dungeon_prog_obj = JSON.parse(localStorage.dungeon_prog);
I want it to override dungeon1_prog "complete" false
to true
when player hits the exit in dungeon 1.
How would I do this? And are the default "false" statements actually being saved in localStorage? Thanks.