Hello,
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.
Thanks
"Attempt to index a nil value"-error in head of if loop
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
"Attempt to index a nil value"-error in head of if loop
- Attachments
-
- Cave Generator.love
- (1.33 KiB) Downloaded 152 times
@pixelwar_studio on twitter
Re: "Attempt to index a nil value"-error in head of if loop
Code: Select all
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
Code: Select all
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
Re: "Attempt to index a nil value"-error in head of if loop
Works. Thanks for the fast answer.
@pixelwar_studio on twitter
Who is online
Users browsing this forum: Google [Bot], rev and 15 guests