Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make Multi-Dimensional Arrays?

Asked by 10 years ago

I am doing something involving grids, and I want to make multi-dimensional arrays. It's like: field[x][y][z] = thingid . how?

EDIT: will this work?

field = {}
for x=1,32 do
    field[x]={}
    for y=1,32 do
        field[x][y]={}
        field[x][y][1]=1
    end
end
field[4][6][2] = 3
for x = 5,12 do
    field[x][3][1] = 2
end
for x=3,14 do
    for y=4,12 do
        field[x][y][1] = 2
    end
end
for x = 5,12 do
    field[x][13][1] = 2
end

Answer this question