2D Array


  • Posts: 591
Hello, testu0sh0!

In my system 2D arrays are technically a lists, so if you want to make a 2D Array, you should add a list attribute and set that attribute to "create new 2D array" block. You should then use this attribute as an "array" parameter for another blocks (e.g. as in: "get item at [ 5 ] [ 7 ] from array [ MyLittleArray ]", where MyLittleArray is an attribute).

Also, if I were to make 2D Array containing lists using my system, I'd do something like this:
Code: [Select]
set MyLittleArray to [create new 2D Array with width: [20] height: [20] default item: [NONE]]
repeat [[20] x [20]] times
  replace item # [[current loop count] + [3]] with [create new list] in [MyLittleArray]
And that's why:
 - the most intuitive solution would be setting default item to [create new list]; however, if this was the case, instead of creating 400 new lists system would add the same list to every single field of array, which we wouldn't want
 - it's "current loop count + 3" rather than "current loop count" because of the way this array is made; the first three items are the information about width, height, and default item, and the other ones are cells

So yes, all you would need to do would be manipulating on each of lists in 2D Array, as in "add [ Something ] to [get item at [ 5 ][ 7 ] from [ MyLittleArray ]]" or so.

Hope this clears things up? ^^'


  • Posts: 49
Seems to work fine :)
Now i just gotta play around with it some more.
Thanks so much!