This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Zoinky's profile picture

[Lua][Question] How do I add things into sub-tables?

Started by Zoinky, 23 March 2013 - 03:04 PM
Zoinky #1
Posted 23 March 2013 - 04:04 PM
Hey, I was messing around with tables and I stumbled upon a problem. I'm not sure how to add things into "sub-tables".

Eg. If I had a table like so:


local exampleTable  = {
 {
   var1 = "Test"
 }
}

How would I add var2 into exampleTable[1]?

I've tried using table.insert() but I can't get it to put things inside the second table. Also, I'm really bad at explaining things. So this might not make any sense.
Kingdaro #2
Posted 23 March 2013 - 04:12 PM
I'm guessing you want to do this?


exampleTable[1].var2 = "Test2"

-- output:
local exampleTable  = {
  {
    var1 = "Test";
    var2 = "Test2";
  }
}
Zoinky #3
Posted 23 March 2013 - 04:18 PM
I'm guessing you want to do this?

-snip-

Lol, thanks. Derp on my part. :P/>