function setup()
for i=0, 100 do
grid[i]
for j=0, 50 do
grid[i][j]
end
end
end
Am I doing something wrong?
function setup()
for i=0, 100 do
grid[i]
for j=0, 50 do
grid[i][j]
end
end
end
Am I doing something wrong?
function setup()
grid = {} -- Grid is NOT NIL!!!
for i=0, 100 do
grid[i] = {}
for j=0, 50 do
--grid[i][j]--But why?
-- Here it will be 50*100 times repeated
end
end
end
EDIT: Also grid = {}
should be only in setup. The others should bein draw, if you want to draw the grid. To draw your grid use line(i * 5, j * 5, i * 10, j * 5)
in the formats where i, j is counting from 0 till 50 (or 100)
@Kire It appears you’re trying to create a two-dimensional array. Your error is coming from not assigning a value to grid[i]
or grid[i][j]
.
First you need to declare grid as a table: grid = {}
Then you need to declare each element of grid as a new table: grid[i] = {}
And then you need to assign whatever value you want to that position: grid[i][j] = "value"
Thank you, very much!