Sync Dictionary with WebStorage

0 favourites
  • 5 posts
  • I have a global Dictionary in my project that I want to use to track statistics like current money count, number of HP upgrades, etc. I also want to save these values to WebStorage.

    I want to:

    1) Load values from Local Storage when the global Dictionary is created

    2) Save values from Dictionary to Local Storage when they are altered (or at the end of a level)

    How can I do this? Is a global Dictionary the best way to go?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can u give me an example capx? Also have you considered using an array and saving/loading as json to Local Storage?

    I'm not sure how that works with dictionary

  • <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/saveDictToWebstorage.PNG" border="0" />

  • ramones

    Just what I was thinking

  • Wow, that was amazingly simple! Thanks!

    EDIT: Bonus question: how do you save objects to a JSON file (or multiple, but preferably one) and load them from said file to transfer save files between computers? Or better yet save them to Dropbox?

    EDIT 2: Never mind the Dropbox; I think the plugin for it should be simple enough when I want it. How about basic save&load to/from file, though?

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