Question

When i try to remove the object from table using the following coding it returns a Bad argument error,

Code

table.remove(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId)
table.insert(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId,tostring(currentTableObj[currentTableCode].status+1))

Error

Bad argument #1 to 'remove' (table expected, got string)

I knew the syntax of removing is

table.remove(tablesArr,currentTableObj[currentTableCode].tableId);

But i want to remove the exact value in

tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"]

How to remove the index value in 2d array in lua,Please help to solve.

Was it helpful?

Solution

If you want to remove value just set it to nil:

tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"] = nil
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top