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: Are there subtables?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
14 Aug 2013 12:35 PM
Like I know that tables are like so:

table = {"blah", "blahdos", "blahdittoditto"}

but can there be subtables?

table = {
subtable{"1", "2", "3"},
subtable2{"uno", "dos", "tres"},
subtable3{"a", "b", "c"}
}

Yes? No?

If there are subtables? how do I string them?

A normal table would be like table[2], and it would return blahdos

how would I do this for a subtable, if they can be done that way.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
14 Aug 2013 12:36 PM
print(table[2]subtable[3] )


would print tres.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
14 Aug 2013 12:37 PM
Oops i mean

print(table[2][3])

*derp*
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
14 Aug 2013 12:38 PM
You can put anything you want in a table, really.

    table = {
        ["subtable"] = {"Hello ", "World!"}, -- One way (setting a string key with []'s and quotes)
        {"Goodbye ", "Cruel ", "World!"}, -- Another way (setting with a default # key)
        subtable2 = {"Hi ", "Again ", "World!"}, -- Third way (setting a string key without quotes)
    }

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
BIGBUCKS999 is not online. BIGBUCKS999
Joined: 26 Feb 2010
Total Posts: 6524
14 Aug 2013 12:38 PM
Do you mean like this:

temas = {
{"Navy blue","Bright green"};
{"Really red","Bright yellow"};
};

for i=1,#teams do
print(teams[i][1] .. " is with " .. teams[i][2] .. "!")
wait()
end

?

- Bigbucks
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
14 Aug 2013 12:38 PM
You'd need to set them up like this:

Table = {
["subtable"] = {"1", "2", "3"},
["subtable2"] = {"uno", "dos", "tres"},
["subtable3"] = {"a", "b", "c"}
}

To print 'dos' you'd need to access it like this:

print(Table["subtable2"][2])

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]-
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
14 Aug 2013 12:42 PM
What if the tables have different names? Is there a way to call the table from a StringValue?

Such if there are 6 subtables, and they are named for elements Fire, Water, Earth, Nature, Light, Darkness. If a StringValue has a value of Fire, can the subtable be called by this?

print(table[StringValue.Value])
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
14 Aug 2013 12:57 PM
table = {
    Fire = {stuff}
}

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
14 Aug 2013 01:03 PM
yes but that doesnt answer my question

Elements = {
Fire = {"", ""},
Water = {"", ""},
Earth = {"", ""},
Nature = {"", ""},
Light = {"", ""},
Darkness = {"", ""}
}

StringValue.Value = Fire

if i call for Elements[StringValue.Value], will it return Fire? Or do tables have to be called by number?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
14 Aug 2013 01:03 PM
tab = {
a = {
a1 = {
a1a = {1, 2, 3};
a1b = {1, 2, 3};
};
a2 = {
a2a = {1, 2, 3};
a2b = {1, 2, 3};
};
};
b = {
b1 = {
b1a = {1, 2, 3};
b1b = {1, 2, 3};
};
b2 = {
b2a = {1, 2, 3};
b2b = {1, 2, 3};
};
};
};

--Have some tables in your tables in your tables!
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
14 Aug 2013 01:08 PM
Tables operate using key, value pairs (sometimes called index, value pairs)
The 'key' can be a number of things, including a string.
When you say
table[something]
That 'somthing' is actually just the key in the table - you're looking up the value
So if you had a table like
table = {
Fire = {"Hello", " World!"} -- Using strings without quotes for setting a key is allowed
}
Then yes, you can say
print(table["Fire"][1] .. table["Fire"][2])
Hope that answers your question

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
14 Aug 2013 01:12 PM
So you're saying the answer is yes. If I call for the StringValue's value, and the value is Fire, it will call for the Fire subtable?
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