• Quick Question about table's
    4 replies, posted
If i wanted to have a table inside of a table how would i call the values inside of it: heres the idea [lua] local table = {} table["anothertable"] = { 1, 2 , 3 } [/lua] now how would i grab the variable from the second index would i call it as: variable = table["anothertable"][1] ???? that seems a little bit weird to me, figured id ask you guys.
Yes, that's how you would do it. I personally like to do it like this, though [code] local f = { h = { 1, 2, 3 } } [/code] I think it's neater, personally.
Alternatively, you could do [lua]var = table.anothertable[2][/lua] Remember that in Lua, table indices start at one, not zero. Lua is strange in that fashion.
[QUOTE=Entoros;22790430]Alternatively, you could do [lua]var = table.anothertable[2][/lua] Remember that in Lua, table indices start at one, not zero. Lua is strange in that fashion.[/QUOTE] Well, they probably didn't want 0, I wouldn't.
[QUOTE=Entoros;22790430]Alternatively, you could do [lua]var = table.anothertable[2][/lua] Remember that in Lua, table indices start at one, not zero. Lua is strange in that fashion.[/QUOTE] I think it's just more intuitive. You'd expect the index #1 to be the first entry of the table.
Sorry, you need to Log In to post a reply to this thread.