gpt4 book ai didi

lua - 表格插入给出零错误

转载 作者:行者123 更新时间:2023-12-04 19:53:58 25 4
gpt4 key购买 nike

我的 lua 代码中有以下函数。我收到一个错误 Attempt to call field 'insert' (a nil value)

我在主 block 上面有

local cardDeck;
local suits = {"h","d","c","s"};

然后在函数中

function createDeck()
cardDeck = {};
for i=1, 4 do
for j=1, 13 do
local tempCard = suits[i]..j;--PRINT SHOW VALID VALUE HERE i.e. "h1","d2" etc
table.insert(cardDeck,tempCard); --THIS LINE IS ERROR
end
end
end

最佳答案

你确定你没有在程序的其他地方定义table吗?

> table.insert({},1)
> table = {}
> table.insert({},1)
stdin:1: attempt to call field 'insert' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?

关于lua - 表格插入给出零错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16410929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com