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 » Scripters
Home Search
 

Re: Tables within tables

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 02:40 PM
local Table = {
Item1 = {},
Item2 = {},
}

for i,v in pairs (Table) do

How do I get the name of each section in the table? Not the contents within, just "Item1","Item2, etc
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Mar 2015 02:42 PM
just give up
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2015 02:43 PM
*Facepalm*
Look at the arguments that the function returned by pairs gives. You already have the variable for it. *Second facepalm*
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 02:45 PM
I have no idea what you just said. If it helps, here's the full-er script


for i,v in pairs (Character:GetChildren()) do
for r,t in pairs (Table) do

if v.Name == t then -- If something in character is named Item1
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2015 02:47 PM
for i,v in pairs(Character:GetChildren()) do
for i,v in pairs
for i,v
i,v

-.-
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 02:50 PM
Help me
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
01 Mar 2015 02:53 PM
i
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
01 Mar 2015 02:54 PM
x = {
Y = {"a"}
}

print(x.Y[1])


billy mays here with special tv offer
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
01 Mar 2015 03:24 PM
The stupid is unbearable
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 03:29 PM
I'm not following
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2015 03:30 PM
for Argument1, Argument2 in pairs(Blah) do
--Stuff
end

Try looking at the arguments again.
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
01 Mar 2015 03:32 PM
for i, v in pairs(tab) --


Pairs will return two values for each iteration of the table -

v, as you've already learned, is the value that the index holds.

i is the index of the table. In your case, i is a string of the names you gave the tables.

I'm sorry for the elitist morons in this thread. They'll die off eventually.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 03:36 PM
I thought i was the number in the sequence. I thought after 10 run throughs, It'd print 10 if I did print(i)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2015 03:36 PM
I try to get people to solve it for themselves, or that's what I keep telling myself. But I decided (before you posted, Lucas) that I probably do it to humiliate people, which is dumb. I resolved then to explain things instead, so that I don't end up doing that.

I have a lot of character issues. Want to hear them all?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2015 03:38 PM
i (or k) stands for Index or Key, which is the position something is at in the table. If you are using an array, not a dictionary, it is the numeric position of the value. In a dictionary, it is the key that is associated with the value.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Mar 2015 03:41 PM
Honestly I don't find it surprising the OP is asking for help in this way. Many people don't actually understand pairs/next or how generic loops actually work but they do it off memory. Working off it by what you remember is a fast way to do it, but not a good way to do it because you don't actually understand the language.

I blame the forums (no offense to all of us, I guess) because a lot of people who learn off the forums see code but not explanation usually. Also a lot of video tutorials I've looked at don't go in depth at all.
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
01 Mar 2015 03:43 PM
Which is why a friend of mine and I are creating a new Lua tutorial roblox game that will go in depth to explain these things.

The two of us are both in college learning the same things we already picked up here long ago. By taking the teaching style of a good college CS professor and adding our own Robloxian spin to it, we think we can reorganize the horrible learning curve of scripting on Roblox.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Mar 2015 03:45 PM
Why make it a game? I think a large PDF or a series of video tutorials would be better since you can easily find what you are looking for, continue off where you left from quickly, and in some cases (if they downloaded the videos or the PDF) they wouldn't need internet connection to learn.
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
01 Mar 2015 03:51 PM
I like that idea too - I hadn't taken into account for accessibility. PDFs are an amazing idea that I'll probably get finished before the game, but I hate making videos because my throat gets dry too fast (lol).
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Mar 2015 04:05 PM
Yes blame the people who give code to everyone who asks instead of linking to the wiki
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
01 Mar 2015 04:12 PM
I look at wiki's before posting most of the time.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
01 Mar 2015 04:14 PM
You already named the index, why do you need to CHECK for the name?!

local tab = {
    one = {1,2,3},
    two = {3,2,1}
}

for i,v in pairs(tab.one) do
    print(v)
end

>1
>2
>3
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
01 Mar 2015 04:15 PM
The Wiki is terrible though... They hardly explain what they do. Simply put most of the tutorials just wave their hand over the code chanting "This works, trust me!"
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Mar 2015 04:17 PM
I do agree the wiki could be better, but for most questions that are asked here, the wiki could do a good job of explaining and if they still don't get it, then programming isn't for them
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
01 Mar 2015 04:18 PM
That's assuming that everyone learns the same way...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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