I get a seemingly well-known error message("attempt to index a nil value") and I found some 'solutions', but no one helps, it's a little bit strange, because I doesn't index something with the critical code. I attach the .love file, hope you can help me.
if i == 0 and j == 0 then
--Do nothing
elseif cave[neighborX][neighborY] == nil then
count = count + 1
elseif cave[neighborX][neighborY] == 1 then
count = count + 1
end
in those elseifs, cave[neighborX] is nil occasionally, so trying to access the [neighborY] of a nil value is throwing the errors. Easily fixed by first checking if cave[neighborX] is notnil.
if i == 0 and j == 0 then
--Do nothing
elseif cave[neighborX] and cave[neighborX][neighborY] == nil then
count = count + 1
elseif cave[neighborX] and cave[neighborX][neighborY] == 1 then
count = count + 1
end
Follow me on GitHub! | Send me a friend request on PSN!