Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一副纸牌。在我的代码的早期,我有以下内容。
suits = {"c","d","h","s"}
我尝试按如下方式创建卡片
cardDeck = {}; for i=0, 3 do for j=1, 13 do local newCard = suits[i]..j; end end
我收到以下错误:Attempt to concatenate field '?' (a nil value)
Attempt to concatenate field '?' (a nil value)
您的索引应该从 1 开始,而不是 0。(我知道这是违反直觉的,但 Lua 就是这样做的)
此代码将实现您想要的:
for i=1, 4 do for j=1, 13 do local newCard = suits[i]..j; end end