generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table in a table?

Previous Thread :: Next Thread 
RoAnt is not online. 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 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
27 Dec 2011 12:52 AM
yyes
Report Abuse
RoAnt is not online. 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
bl5eebryce is not online. bl5eebryce
Joined: 03 Aug 2009
Total Posts: 387
27 Dec 2011 12:58 AM
The second one needs to be in brackets
Report Abuse
RoAnt is not online. RoAnt
Joined: 14 Jul 2008
Total Posts: 16794
27 Dec 2011 01:01 AM
print(skies[1[1]])

that doesn't work.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
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 is not online. 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
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
27 Dec 2011 01:05 AM
Lolsmurf.
I win :3

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
smurf279 is not online. 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 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
27 Dec 2011 01:08 AM
nubcaik
stop making me early toast >:U
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
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 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
27 Dec 2011 01:24 AM
nubcaik troll >:U
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
27 Dec 2011 01:27 AM
UJellyBro? <3

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
RoAnt is not online. 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
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image