我不确定问题出在哪里.谁知道为什么?
function check(board, color, row, col)
--if same color, change tile to "o"
if board[row][col] == color then -- attempt to index nil?
board[row][col] = "o"
count = count + 1
return "o"
end
return
Run Code Online (Sandbox Code Playgroud)
结束
问题是board[row]没有定义; 它是nil.所以你要努力做到nil[col].
您可以通过执行以下操作来避免此错误:
if board[row] and board[row][col] == color then
Run Code Online (Sandbox Code Playgroud)
代替.
但是,我建议您查看创建板的方式 - 例如,确保您没有错误地在代码中的某处切换行和列.