Save array information

  • I just tried to export my game with the webnode kit.

    The thing is.. As long as I am in the game, the array information works fine between Layouts. But when I exit the game and start again... All the chosen information is lost.

    Maybe I misunderstood the use of arrays. Is it not supposed to store the information somewhere in the file?

  • Yup, arrays themselves don't save the data between restarts. Look into web storage object, that would probably work for you.

  • To save

    On Trigger -> WebStorage: Set local key "x" to "y".AsJSON

    to load

    WebStorage: Local key "x" exists -> "y": Load from JSON string WebStorage.LocalValue("x")

    Trigger - condition where You want to save your array (On button press, On collision...)

    "x" - name of the local value you want to save (can be anything "aaa", "save"...)

    "y" - Array object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So... If I use the web storage, I will have to ditch my arrays and arrange the values in web storage instead?

    There must be a way to save array information between sessions or the world will implode.

  • You can save your arrays as JSON, and put the JSON into a webstorage key as shinkan suggested.

    <img src="http://i.imgur.com/UXHZH28.png" border="0" />

  • Thanks for cutting it out for me Zatyka... I get it now! :)

    Ty for the replies all.

  • Using Haematite's post, the capx I downloaded works. But using the same events in my project and a little test layout will not work. It returns as if no data was saved.

    Can Anyone tell me what I am doing wrong? Is it case sensitive?

    <img src="http://justpaste2wnd" border="0" />

    Thanks, Ed

  • It appears My image link is rejected also. :(

    justpaste.it/2wnd

    http://justpaste.it/2wnd

    <a href="http://justpaste.it/2wnd">http://justpaste.it/2wnd</a>

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