Stencyl 3.4.0 is now out. Get it now!

2D List Extension

Photon

  • Posts: 2698
HELP PAGE: http://photongamedev.wordpress.com/stencyl-corner/photons-extensions/2d-list-extension/

This is something I've been working on over the past week and I'm now ready to share! 2D Lists can be difficult to deal with using the normal list blocks, so I've made a slew of blocks designed specifically for handling the making and manipulation of 2D lists. My hope is that they are intuitive to use and that they are easier in general to work with, thus making this important data structure a bit less painful to utilize!

I've done quite a bit of testing, so I'd like to get it out there and see how it fares. Although I may add some more features in the future, current features include things such as:

  • Generating and copying 2D lists
  • Getting, setting, clearing, and even swapping entries in 2D lists
  • Blocks for working with single entries, rows, and columns

Some important notes:

  • Do not use the resulting 2D lists with the normal Stencyl list blocks! The 2D list blocks are built under the assumption that only they are manipulating the 2D lists, particularly when checking dimensions.
  • Currently, 2D lists are meant to maintain a static, unchangeable size. Consider this carefully when choosing initial dimensions. This will likely be modified in future versions.
  • Trying to index out of the 2D list range will return "-1" for "number of" blocks and "null" for all other pertinent blocks.

I am also planning on putting a help page on my blog. The current help link will direct users to the help home I have.

Feedback is appreciated. Enjoy!

« Last Edit: March 10, 2014, 03:45:29 pm by Photon »
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Dom818

  • *
  • Posts: 1296
Lol, now there are two 2D list extensions. I wrapped a 2D lists into my List Utils extension a while ago.

Photon

  • Posts: 2698
Lol, now there are two 2D list extensions. I wrapped a 2D lists into my List Utils extension a while ago.
I'm actually planning on using this in an upcoming game idea I have. I also plan on writing some "advanced" blocks (such as "rotating" the lists and grid-style collisions), so its why I wrote something to cater to that and make the 2D lists behave akin to grids. That being said, it wasn't super-specialized, so I thought it would be useful to share all the same. :)
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Dom818

  • *
  • Posts: 1296
Ohh, that makes sense then. My 2D arrays are more loosely put together so the user has more flexibility when sizing them.

Photon

  • Posts: 2698
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Jorj

  • Posts: 78
I am the only one missing the *** is entry at column# (x) [Number], row# (y) [Number] from 2D list
    empty? *** function ?

SadiQ

  • Posts: 1689
It seems that it is missing, but you can still use the Get entry from column and row block to perform that check.

@Photon: Why not some sort of "Populate entire 2d list with value []" block ?

« Last Edit: February 25, 2014, 09:16:43 am by SadiQ »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Jorj

  • Posts: 78
yes I figured that. but to what I compare it ? I tried with _null, null, null as text, 0,.... nothing works...

SadiQ

  • Posts: 1689
Put null inside a code block (Found under Flow -> Advanced -. code[])
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Jorj

  • Posts: 78
yes it works now.
thank you very much.

and I agree with you, Photon should insert some block to populate array.

SadiQ

  • Posts: 1689
When trying to see if an entry in that list is equal to a number I got the following error:
List2D.hx:70: characters 10-14 : On static platforms, null can't be used as basic type Int

I guess populating the list before performing that check would solve this problem.


« Last Edit: February 26, 2014, 10:37:59 am by SadiQ »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2698
Whoops. It would appear that somehow I managed to upload an incomplete version. Sorry about that. I've attached it here.

I see what you're saying about the population thing. I still might consider posting an update in the future.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

SadiQ

  • Posts: 1689
I had to replace list_column = [for(x in 0...r_amount) null]; with list_column = [for(x in 0...r_amount) 0]; and I had to return 0 in  the get_entry function to get it to work for me.
Having a populate list block would be better in case somebody actually needs 0 in their values and would like to populate the list with something like -1.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

rustemk

  • Posts: 1
Hello friend! How can I download and install your 2d List Extension? Did not found any download links..

Photon

  • Posts: 2698
Its an attachment on the original post.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!