I've got a piece of code, trying to insert some values into a table, as below.
local table1, table2, table3 = {}
function somefunction(inputtable)
for k,v in pairs(inputtable) do
if k == "1" then
table.insert(table1, v)
elseif k == "2" then
table.insert(table2, v)
end
end
end
I get an error referencing one of the table insert lines, like this:
extractorController.lua:34: bad argument #1 to 'insert' (table expected, got nil)
stack traceback:
[C]: in function 'insert'
extractorController.lua:34: in function 'somefunction'
[C]: in function 'xpcall'
machine:751: in function 'xpcall'
/lib/process.lua:78: in function </lib/process.lua:71>
stack traceback:
[C]: in function 'error'
/lib/process.lua:92: in function </lib/process.lua:71>
Clearly I'm defining these tables at the start of the file...so I'm not sure why this is occurring...? I'd really appreciate some help figuring this out! Thanks.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I've got a piece of code, trying to insert some values into a table, as below.
I get an error referencing one of the table insert lines, like this:
Clearly I'm defining these tables at the start of the file...so I'm not sure why this is occurring...? I'd really appreciate some help figuring this out! Thanks.
Link to post
Share on other sites