nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:29 PM |
For an example:
Tab = {Tab1 = {Tab2 = {}}}
Now say I only have access to Tab2, how would I access Tab1 and Tab2, since I do not know of something similar to "Part.Parent"?
|
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 19 Aug 2011 03:30 PM |
tab1 = {tab2 = {tab3 = {"LOLWUT"}}}
print(tab1.tab2.tab3[1]) |
|
|
| Report Abuse |
|
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:31 PM |
@Dekkonot
You have only access to tab3, so to access tab2 or tab1 you will need something like:
Tab2 = Tab3.Parent Tab1 = Tab2.Parent
However... Tables do not have this parent property? |
|
|
| Report Abuse |
|
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:34 PM |
"Why are you even asking this?"
Answer my question first please. |
|
|
| Report Abuse |
|
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 19 Aug 2011 03:35 PM |
tab1 = {tab2 = {Parent = tab1, tab3 = {Parent = tab2, lol = "LOLWUT"}}, lolwut = "I win"}
print(tab3.Parent.Parent.lolwut) |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:38 PM |
Ok... Let me explain this a bit more. Someone gave me a variable called "Tab3", and he said that this variable is a table.
Now he told me - find out if this variable is inside a table or not. How would I figure that out? |
|
|
| Report Abuse |
|
|
GollyGreg
|
  |
| Joined: 22 May 2008 |
| Total Posts: 21835 |
|
|
| 19 Aug 2011 03:38 PM |
local stuff = { My_stuff = {"StringA",2,"blah blah"}, His_stuff = {"StringB",2,"blah blah"}, Your_mothers_stuff = {"StringC",7,"blah blah"}, }
You can call it by doing
stuff["My_stuff"][1] or stuff.My_stuff[1]
You can even just store variables instead of entire tables. Like:
local stuff = { JacobsFavColor = "Red" StevesFavColor = "Blue" } print(stuff["JacobsFavColor"]) >Red |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
| |
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:42 PM |
@Dekkonot
Yes I know. However, this person created a table which looks like this:
Tab1 = {Tab2 = {Tab3 = {}}}
He didn't show me that ^, all he said: "There is a variable called "Tab3" which is a table, find out if it is inside a table or not."
I am oblivious to the fact that there is Tab2 and Tab1. |
|
|
| Report Abuse |
|
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
myrco919
|
  |
| Joined: 12 Jun 2009 |
| Total Posts: 13241 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
| |
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 19 Aug 2011 03:44 PM |
| No way that has been documented. Figure it out, then tell me so I look smart. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:47 PM |
"No way that has been documented. "
It hasn't been documented. That is why I am asking if some "Lua genius" can give me an answer other than "Impossible".
Also "he" is just a hypothetical character I made to explain myself. |
|
|
| Report Abuse |
|
|
|
| 19 Aug 2011 03:48 PM |
Table = {Taco = {}} is the same as Table = {} Table.Taco = {}
So you can print(Table.Taco) or print(Table["Taco"]) |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 19 Aug 2011 03:48 PM |
| Can you use table:getChildren() |
|
|
| Report Abuse |
|
|
bombpaw
|
  |
| Joined: 15 Mar 2009 |
| Total Posts: 3484 |
|
|
| 19 Aug 2011 03:48 PM |
"Ok... Let me explain this a bit more. Someone gave me a variable called "Tab3", and he said that this variable is a table.
Now he told me - find out if this variable is inside a table or not. How would I figure that out?"
He told you it was in a table..... Simple answer :P
-I got bomb in my.... Paw? |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:49 PM |
@Oysi
HE DIDN'T SHOW ME HOW HE MADE THE TABLE!!!
All I know is that there is a variable called: Tab3
And he asked, find a way to figure out if Tab3 is inside a table or not. If it is inside a table show him how I worked it out, and if it isn't - give him a reason why.
|
|
|
| Report Abuse |
|
|
|
| 19 Aug 2011 03:50 PM |
Oh I see what OP means....
Table = {} Table.Taco = {} Table.Taco.Parent = Table
Just do that. print(Table.Taco.Parent == Table) ==> true |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 19 Aug 2011 03:50 PM |
@Capictator
The problem is I cannot do:
Table.taco
since I do not know if taco is inside a table nor do I know the table's name. Iy-ya-yah... |
|
|
| Report Abuse |
|
|