Attempt to index field nil value

Hi I have array
[lua]tab = {}
tab[1] = {0,1,0,0}
tab[2] = {0,0,0,0}
tab[3] = {0,0,0,0}
tab[4] = {0,0,0,0}[/lua]

and
[lua]function poziom(event)
for i = 0, kLevelCols do
for j = 0, kLevelRows do
if tab[i][j] == 1 then
schodek = display.newImage(“schodek.png”)
physics.addBody(schodek, “static”, {bounce = 0.3, friction = 0.2})
schodek.y = 260
schodek.x = 260
end
end
end
end
Runtime:addEventListener( “enterFrame”, poziom )[/lua]
Corona symulator output give me :

attempt to index field '?' (a nil value)

Place where error shows is bolded [import]uid: 117910 topic_id: 21231 reply_id: 321231[/import]

You loops start at 0

Your array starts at 1

your indexing to tab[0][0] which does not exist? [import]uid: 106158 topic_id: 21231 reply_id: 84082[/import]

Lua is a 1 index based language, not 0 based like C based languages.
[import]uid: 19626 topic_id: 21231 reply_id: 84087[/import]

It’s work :slight_smile: Thanks for help [import]uid: 117910 topic_id: 21231 reply_id: 84178[/import]