RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 27 Dec 2011 12:50 AM |
Could I make a table inside a table? For example:
local ex={ first={}, second={}, third={}} |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
| |
|
RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 27 Dec 2011 12:55 AM |
Okay.
local skies={first={"hi","bye"},second={"hi","bye"}}
print(skies[1(1)]) -- ERROR HERE
How do I print it? |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2011 12:58 AM |
| The second one needs to be in brackets |
|
|
| Report Abuse |
|
|
RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 27 Dec 2011 01:01 AM |
print(skies[1[1]])
that doesn't work. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2011 01:01 AM |
local skies={first={"hi","bye"},second={"hi","bye"}}
print(skies["first"][1]) --> hi
Keep in mind that you have to call it by the index, which wouldn't be 1, but 'first'. Also, you would call the index, then an index for that table as I did above.
"I WILL GIVE YOU BACON." - Deadmau5 ~Scarfacial |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 27 Dec 2011 01:04 AM |
You set the index of the table to first not 1 _______________________________________
tab ={"a"} Is just the same as writing tab = {1 = "a"} or tab= {} tab[1] = "a"
and
tab {one = "a"} is just like writing tab[one] = "a" _________________________________________
with what your doing you set the index of your table to first but your trying to index it by its position in 'skies'. All you need to do to fix it is change
skies[1(1)] to skies[first][1]
probably a latetoast. Couldn't think of a good way to explain what you were doing wrong. . . |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2011 01:05 AM |
Lolsmurf. I win :3
"I WILL GIVE YOU BACON." - Deadmau5 ~Scarfacial |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 27 Dec 2011 01:07 AM |
And scar beats me to it. Only thing is I forgot the quotes
probably another latetoast. . . |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 27 Dec 2011 01:08 AM |
nubcaik stop making me early toast >:U |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2011 01:08 AM |
You mean latetoast? No matter. I'm stealin all your toasts anyways.
"I WILL GIVE YOU BACON." - Deadmau5 ~Scarfacial |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
| |
|
|
| 27 Dec 2011 01:27 AM |
UJellyBro? <3
"I WILL GIVE YOU BACON." - Deadmau5 ~Scarfacial |
|
|
| Report Abuse |
|
|
RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 27 Dec 2011 01:30 AM |
I was about to make my code even simpler... but now it just got more complex. Uh... not complex but longer. I hate long stuff. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2011 01:33 AM |
When I use tables within tables (tableception?), I do it like this:
local tab={ {"String", "Some value"}; {"Another string", "Another value"}; {"Yet another string", "But no value >:l"}; }
So you can simply do print(tab[1][1]) with purely numerical values. I use tables a lot, they're quite nice once you get the hang of them.
"I WILL GIVE YOU BACON." - Deadmau5 ~Scarfacial |
|
|
| Report Abuse |
|
|
RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 27 Dec 2011 01:36 AM |
@SCARFACIAL
OMG! I can't believe I didn't thought of that! THANKS! That was what I was aiming for.
Tableception. :D
|
|
|
| Report Abuse |
|
|