Jump to content




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


  • You cannot reply to this topic
2 replies to this topic

#1 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

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.

#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

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";
  }
}


#3 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 23 March 2013 - 04:18 PM

View PostKingdaro, on 23 March 2013 - 04:12 PM, said:

I'm guessing you want to do this?

-snip-

Lol, thanks. Derp on my part. :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users