We need a way to loop through the Webstorage

0 favourites
  • 4 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hey all,

    A mysteriously missing feature from C2 for some time now is the ability to loop through all the webstorage values for a game. This might seem a bit useless, so I'll try to illustrate my current predicament.

    I have a 'save slot' system which works by prefacing every webstorage value with a slot value - e.g. "Score" becomes "1_Score" for slot 1, "2_Score" for slot 2. I set up functions to do this all automatically, and it works well.

    The problem comes when I'm trying to clear a slot by removing all the webstorage values prefaced with that slot value. I've been attempting to find a way to workaround, and it all comes down to the fact that we can't loop through the webstorage like we can for a dictionary, even though the two systems are functionally identical.

    Any thoughts?

  • Basically I put all my variables into a dictionary and then save the dictionary in json format into the slot.

    I can loop over the slots to do things like find an empty slot or whatever.

    To clear a slot I just set it to an empty string (thus overwriting the json dictionary saved there).

  • ggibson1 that's not a bad idea. I might give that a try...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • you can also I think load the webstorage into a dictionnary directly, then load it back to the webstorage.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)