project file <--> web storage

  • I would like to have a confirmation on this before I build something that goes the wrong direction.

    Scenario:

    An app needs a lot of initial values for various items. But those values will change depending on the user's actions. When leaving the app and later return, the last state of the values should be restored rather than the initial one's.

    My logic:

    I save a dictionary with the initial values as a JSON file and import it as a project file. On start of layout that JSON file is requested using Ajax.Request(project file) and then loaded via Dictionary.Load(Ajax.LastData)

    When user changes values I store the dictionary's JSON string as a value to a key in web storage.

    Next time the user starts the app, an on-start-of-layout-event checks if the key exists in web storage via local-key-exists-condition. If true I load the key's value to the dictionary via dictionary.Load(webstorage.localvalue(key))

    Can anyone confirm that this is correct (without spending hours on testing it, just based on experience)? Is there a simpler way?

  • Sounds like the system save might work for you.

  • I also thought about it, but system save introduces other issues with this app that I would like to avoid.

    I'll wait a while if someone has already worked with JSON, Ajax and web storage in a similar way and can confirm, else I'll do some experiments.

  • tulamide

    ummm. B. I. N. G. O,   B. I. N. G. O, and bingo was his name oh!

    umm. yes that will work. although I tend to forgo the original export to file. but yes. that's exactly the process you want to do.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jayderyu

    Thank you very much! It's a relief that I can do it this way. <img src="smileys/smiley1.gif" border="0" align="middle" />

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