I’ve spent ages trying to figure this out, but I’m obviously missing something, I’m trying to insert into a table using a variable for the tablename, the code looks something like this
--Create 3 empty tables
TableNum1 = {}
TableNum2 = {}
TableNum3 = {}
--Get a random number 1,2 or 3
ranNum = math.random(3)
--Concat the number onto TableNum store in variable tableName
tableName = 'TableNum'..ranNum
--Try to insert into the table
table.insert(tableName,'whatever')
I get the error:
bad argument #1 to ‘insert’ (table expected, got string)
Any ideas, I feel like I’m missing something, but I’ve no idea what
[import]uid: 36590 topic_id: 7957 reply_id: 307957[/import]
