[SOLVED] Another 'attempt to index a nil value' error issue

Hi, I’m pretty new to Defold and Lua - I keep running into this error when attempting to index the very first value (setting self.board[i][j]) - i’ve tried to see if any indexes or even values are nil at any point (via my 6 print functions sorry) but nothing is.

This code works perfectly fine when I set the index to [y], generating a full grid with the rows and columns specified, but I don’t know why it doesn’t with i and j because they are never nil (as far as I’m aware - they both start at 1) - what’s wrong here and how do I fix this ??

the function:

output & error message (stops at the first instance):

Any help would be much appreciated!!

1 Like

Try debbuger. You will see all values.

You create table for x. But use i as index

self.board[x] = {}

Wrong is that self.board[i] is nil

4 Likes

you’re so right sorry I made such a silly mistake :sob: thank you for your time!!

2 Likes