|
| 09 Sep 2016 04:46 PM |
Dumb question, maybe.
local teams = { Tourists = {nil,'Tourists','New Yeller'}; Developers = {1174589, 'Developers','Lime Green'}; }
- I'm trying to access the values inside the tables within the table. For example, I want to say Tourists[3] and have it print 'New Yeller' Code Example:
for i,v in pairs(teams) do
for i,x in pairs(v) do
print(x[3]);
end
end
prints: New Yeller, Lime Green
Ideas? |
|
|
| Report Abuse |
|
|
Afro_Sub
|
  |
| Joined: 16 Jun 2013 |
| Total Posts: 1114 |
|
| |
|
Skelris
|
  |
| Joined: 02 Jan 2009 |
| Total Posts: 4785 |
|
| |
|
|
| 09 Sep 2016 04:47 PM |
| 16:47:27.078 - Players.Player1.PlayerGui.TEAMS:12: attempt to index field '?' (a number value) |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2016 04:50 PM |
local teams = { Tourists = {nil,'Tourists','New Yeller'}; Developers = {1174589, 'Developers','Lime Green'}; }
print(teams.Tourists[2])
why not use dictionaries?
local teams = { Tourists = { ID = nil; Name = "Tourists"; Color = BrickColor.new("New Yeller"); }; Developers = { ID = 1174589; Name = "Developers"; Color = BrickColor.new("Lime Green"); }; } print(teams.Tourists.Name) print(teams.Developers.Color.Name)
|
|
|
| Report Abuse |
|
|
|
| 09 Sep 2016 04:51 PM |
local teams = {
Tourists = {nil,'Tourists','New Yeller'}; Developers = {1174589, 'Developers','Lime Green'}; }
- I'm trying to access the values inside the tables within the table. For example, I want to say Tourists[3] and have it print 'New Yeller' Code Example:
for i,v in pairs(teams) do
for i,x in pairs(v) do
print(x[3]);
end
end
prints: New Yeller, Lime Green
Ideas? local teams = {
Tourists = {nil,'Tourists','New Yeller'}; Developers = {1174589, 'Developers','Lime Green'}; }
- I'm trying to access the values inside the tables within the table. For example, I want to say Tourists[3] and have it print 'New Yeller' Code Example:
for i,v in pairs(teams) do
for i,x in pairs(v) do
print(x[3]);
end
end
prints: New Yeller, Lime Green
Ideas? local teams = {
Tourists = {nil,'Tourists','New Yeller'}; Developers = {1174589, 'Developers','Lime Green'}; }
- I'm trying to access the values inside the tables within the table. For example, I want to say Tourists[3] and have it print 'New Yeller' Code Example:
for i,v in pairs(teams) do
for i,x in pairs(v) do
print(x[3]);
end
end
prints: New Yeller, Lime Green
Ideas? |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2016 04:52 PM |
use a Dictionary like I stated
much cleaner and acts like they have parent-child relationship like roblox objects |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2016 04:53 PM |
| I rather do it, so I don't have to constantly add it manually. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2016 04:57 PM |
| yea and it sorts everything nicely so if you have like 10 indexes in your table, you might accidentally cause errors by missing or skipping a spot |
|
|
| Report Abuse |
|
|