hi, i’m new in lua and can someone can show me how display a double dimension table please
local cells = {}
for i = 1, 10 do
cells[i] = {}
for j = 1, 10 do
cells[i][j] = 0
end
hi, i’m new in lua and can someone can show me how display a double dimension table please
local cells = {}
for i = 1, 10 do
cells[i] = {}
for j = 1, 10 do
cells[i][j] = 0
end
Just run the same loops:
for i=1,#cells do for j=1,#cells[i] do print( 'cells['..i..']['..j..']='..cells[i][j] ) end end
(this only works if it is really a double-dimensioned array … if you add something like “cells.foo=42”, the above won’t work properly)
Just run the same loops:
for i=1,#cells do for j=1,#cells[i] do print( 'cells['..i..']['..j..']='..cells[i][j] ) end end
(this only works if it is really a double-dimensioned array … if you add something like “cells.foo=42”, the above won’t work properly)