Lua 是否尝试索引字段?(零值)
我不确定问题出在哪里。有人知道为什么吗Lua 是否尝试索引字段?(零值),lua,coronasdk,Lua,Coronasdk,我不确定问题出在哪里。有人知道为什么吗 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 结束问题是未定义板[行];它是nil。因
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
结束问题是未定义
板[行]
;它是nil
。因此,您正在尝试执行nil[col]
通过执行以下操作,可以避免此错误:
if board[row] and board[row][col] == color then
相反
但是,我建议您检查board的创建方式——例如,确保您没有错误地在代码中的某个地方切换行和列