togFox wrote: ↑Sat Apr 10, 2021 3:41 am
Code: Select all
local map = {
{0,1,0,1,0},
{0,1,0,1,0},
{0,1,1,1,0},
{0,0,0,0,0},
}
for i,_ in ipairs(map) do
for j, _ in ipairs(map) do
io.write(map[i][j] .. " ")
end
io.write('\n')
end
io.write('\n')
Pretty straight forward? Console says:
Where did the last column go?
its just because your second cycle is incorrect
you have 4 sections in your "map" table : map[1],map[2],map[3],map[4]
and you are passing through i ={1,2,3,4}, j={1,2,3,4}
so, because of this you are messing 5th column
you should write
for j=1,5
or
for j=1,#map
( if it will work, I'm not sure about second option xD)
or just like this for j, _ in ipairs(map[ i ]) do