Hey there LuNcHbOx...
I haven't tried my hand at lua yet, but looking at your sample code, one possibility springs immediately to mind (drawing from my experience with other programming/scripting languages)
1)"pieces" is an array with four nested arrays, right? If it is then you need to initialize pieces as an array, as well as the four nested arrays. i.e. pieces should be defined as (changed code is in bold font):
pieces = {{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}}
In other words, those four sets of brackets need to be in an all-incompasing set of brackets themselves (hence the term "nested array" -- all array values are "nested" in the array brackets, so any array which is in itself another array's value is a "nested array")
in JavaScript you would define it this way:
pieces = [[0,0,0,0],
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]];
and then when you try to acces pieces[1][2], it will return the correct value. (Except that JS arrays are 0-based and lua arrays appear to be 1-based, but aside from that technical difference, which results in a different value being returned, I expect that the underlying methoud for storing and accessing values is pretty much the same.)
I found basic lua programming instructions at:
http://www.lua.org/pil/
with specific information about lua arrays at:
http://www.lua.org/pil/11.1.html
...Doesn't look like it has any information directly pertaining to your problem, but I hope what I wrote above will help solve it for you. If it doesn't, my appologies!! Does anyone else out there have any input to solve this problem? As soon as I can find information about running lua in OSX I hope to have a go at the language myself and it would be nice to know about any stumbling blocks in the coding process beforehand.
Good luck
Bookmarks