Simplifying webstore, dictionary and array

  • https://dl.dropboxusercontent.com/u/61666915/zeroArray.capx

    zeroArray example

    i added an alert, the event after the loop (thats the same as the end of the loop)

    a subevent of the loop will be executed every iteration, but an event with loop as subevent, you can still run another subevent that will not iterate

  • [quote:24fbi7zo]3. webstore can only be conveniently loaded via json to a dictionary, so if i want it sorted, i have to transfer the dictionary to an array

    4. to delete selection items in a list from the webstore its necessary to either keep track of the key of each item in the list, or to use the name of the item in the list as ke

    You seem to be saving each item in the list as a separate WebStorage value and then loading all of WebStorage into a dictionary to load it. It would be easier to keep the items in an array and save/load the array.

  • That's perfect. Thank you for the example and effort.

    Indeed, i didn't think about adding the whole json list, in json, to webstore; but stored each value individually. Your solution is a great simplification because it avoids the need to use dictionary as intermediary.

    Also, it shows that dimension 0,1,1 does work!.

    Dan

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://dl.dropboxusercontent.com/u/61666915/zeroArray.capx

    zeroArray example

    i added an alert, the event after the loop (thats the same as the end of the loop)

    a subevent of the loop will be executed every iteration, but an event with loop as subevent, you can still run another subevent that will not iterate

    BTW, It looks like this example uses a latest C2 beta version 165?, instead of the current official release 163.

  • ramones,

    BTW, one side effect of storing the whole array in one webstore key is that duplicates need to be dealt with explicitly during add; but its very simply done, just by adding another condition: that the value entered is not already contained in the array.

    again, many thanks,

    Dan

  • This thread would be better suited for the "How do I"-forum. It's not surprising that a beginner hasn't figured out how to effectively use every part of Construct 2, it's obviously not even expected.

    But please don't let it be your first impulse to go around and ask for changes in Construct 2.

    There is an usually overlooked plugin, which can create named 1D arrays. I found this very useful early on and am still using it occassionally. Just thought it might be of interest in this context: Data structures plugin

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