I have a puzzle board with 36 (4 3x3 squares) squares. Some of the squares are "holes" that the character can fall into. Every move, the holes are supposed to shift down. I need to program the script to recognize which square the player is on and whether or not it is a hole. I can figure it out if I have 36 individual variables representing each square, but I was just trying to find a less cumbersome way about it.
This is great case for a 2 dimensional array - you could have an array for each square, with 9 indexes (indices? oh, hell):
var squareOne[2][2] // Has indexes of 0-2
var squareTwo[2][2]
var squareThree[2][2]
var squareFour[2][2]
Then you use them like a matrix. For example, squareOne would look like this, each slice of the array represents a column or row. Visually, it looks like this:
[0,0], [0,1], [0,2]
[1,0], [1,1], [1,2]
[2,0], [2,1], [2,2]
So, if you wanted to manipulate the middle square value, just reference squareOne[1][1] in your code. Or the bottom left square would be [2][0].
If you really want to get crazy, you might be able to do a three dimensional array, but I'm not sure if the compiler can handle it:
var multiDimArray[3][2][2]
...where the first dimension is the square number, the 2nd the column, and the 3rd the row. Doesn't have to be laid out exactly this way, you can shuffle the dimensions any way you like (2-3-2, 2-2-3, you get the idea)
Actually, I don't even think I've tried a 2D array with the compiler. Guess I'd better test that...