This is the help page for my Stencyl 3.0 2D list extension. Please view both the “Block Overview” and “Q&A” so that you thoroughly understand how this extension is set up.

**Block Overview**

**generate new 2D with [Number] rows and [Number] columns:**** **

Returns a new 2D list with the specified rows and columns. This list can be stored in a Stencyl list attribute just like any other list.

**[height/width] of 2D list [List]:**** **

Returns the specified dimensions of the list as a number.

**get entry from column# (x) [Number], row# (y) [Number] from 2D list [List]:**** **

Returns the value at the specified location of the supplied 2D list. Remember that the start of a list is indicated by 0, not 1. For consistency’s sake with general list functionality, the same holds true for this 2D list extension.

**is entry at column# (x) [Number], row# (y) [Number] from 2D list [List] empty?:**

Checks to see if the specified location of the supplied 2D list is empty (equal to null). If empty, true is returned. Otherwise, false is return.

**replace entry at column# (x) [Number], row# (y) [Number] with [Anything] from 2D list [List]:**** **

Grabs the specified location of the supplied 2D list and overwrites the value at it with the new value given.

**clear entry at column# (x) [Number], row# (y) [Number] from 2D list [List]:**** **

Clears (makes equal to null) the specified location of the supplied 2D list.

**swap [rows/columns] # [Number] and # [Number] in 2D List [List]**

Takes the pair of specified rows/columns of the supplied 2D list and switches their positions. Entry-wise, that means if you switch rows (y) 1 and 3, values at [0][1] and [0][3] switch places, values at [1][1] and [1][3] switch places, and so on and so forth.

**swap entries ( x: [Number] , y: [Number] ) and ( x: [Number] , y: [Number] ) in 2D List [List]**

Takes the two specified locations of the supplied 2D list and switches their values.

**copy of 2D list [List]**

Generates a new 2D list with same dimensions and values as the supplied 2D list.

**copy of [row/column] # [Number] as single list from 2D list [List]**

Generates a new single dimension list (so a traditional Stencyl list attribute) with the same values and dimensions as the specified row or column. As the word “copy” implies, modifying values in the returned list does not affect the row or column in the original 2D list.

**number of non-empty entries in 2D list [List]**

Returns the number of locations in the 2D list that are occupied (not equal to null).

**number of non-empty entries in [row/column] # [Number] in 2D list [List]**

Returns the number of locations of the row or column in the 2D list that are occupied (not equal to null).

**Q&A**

**How can I store these lists for future use?**

They are just lists of lists. So as mentioned previously, they can be stored in list attributes. Do not, though, use normal Stencyl list blocks with them (see below).

**What does the term “null” mean?**

Its programming jargon, in essence, for saying nothing or empty.

**Can I change the dimension of my 2D list after its been generated?**

No, or at least you are not supposed to. Dimensions are meant to stay the same, so consider carefully what you want them to be before generating your list. The reason for this is for some simplistic “error-checking”; if you do modify the dimensions, some blocks may not behave like expected.

This may change in the future with the addition of new blocks.

**Can I use Stencyl’s built-in list blocks to work with 2D lists?**

No, or again at least you are not supposed to. Its for the same reasons mentioned above. The 2D list extension expects the 2D lists to “behave” a certain way, and using the built-in blocks can mess with that. For instance, since dimensions are not meant to change, using the “add anything to list” block (thus changing dimensions) can cause potential problems.

The core functionality supplied by the extension blocks should suffice for most operations you might want to perform.

**Do I absolutely have to use the “number of” blocks from this extension as opposed to the “number of” blocks from Stencyl?**

Absolutely? No. If you want things to work right? Yes.

In order to maintain static dimensions, 2D lists are populated with “null” values at generation. A 3×3 2D list, for instance, populates all 9 of its entries with “null”. This is, again, for dimension checking.

The “number of” blocks from Stencyl, however, count “null” values as entries. That means any row or column in the above-mentioned list will always be read as having 3 entries even if they are “null” when using the Stencyl block (in essense, it returns the dimensions, not the number of meaningful values). Therefore, use the extension blocks. Period.

## Leave a Reply