I have the following function in my lua code. I am getting an error Attempt to call field 'insert' (a nil value)
I have above in main chunck
local cardDeck;
local suits = {"h","d","c","s"};
then in function
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
Are you sure you haven't defined table elsewhere in your program?
> 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]: ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With