I have a game where I have redefine keys screen.
When I redefine the keys (press key for left, key for right etc.) they're put into an array and then I loop through that array to set global variables.
But this of course isn't persistent between sessions. What would I do to save and then load that array?
I suppose the answer is localStorage? But I can't work out how it works. Do I need a dictionary? JSON? Something else?
I personally put them in a dictionary but array will work just fine aswell. The basic setup is pretty simple. I'd put them in functions and not "on start of layout" so you call them when you need them.
You should keep in mind all possible cases that can happen. E.G. the first time the player starts the game the item does not exist. You can check first if the item exists and if it's missing you load a default configuration at first etc.
Develop games in your browser. Powerful, performant & highly capable.
Brilliant, that's really clear and helpful. Thanks!
So you just save the whole array/dictionary to one item in LocalStorage? That makes things much clearer.