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: tables

Previous Thread :: Next Thread 
cxcharlie is not online. cxcharlie
Joined: 26 Aug 2009
Total Posts: 1414
13 Aug 2013 11:42 PM
function derp(perks)--perks is an object inside a table
return tostring(perks.Name),#perks
end

hi,amount = derp(game.Workspace:GetChildren())

why would amount return nil? (even though there are stuff in workspace)

shouldnt it return length?
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
13 Aug 2013 11:48 PM
The "#" operator only returns the number of consecutive non-hashed values. That means counting up from 1, to the first missing number and using the numbers as indexes. So, if you want to get the length, keep track of every time you add an object to the list and increment a value, or use next() or pairs() to add up all of the values.
Report Abuse
cxcharlie is not online. cxcharlie
Joined: 26 Aug 2009
Total Posts: 1414
13 Aug 2013 11:52 PM
im still having a little trouble understanding the next() and pairs() idk how to use them
is there a page on roblox wiki in which i can see how to use them?
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
13 Aug 2013 11:55 PM
Pairs:
http://wiki.roblox.com/index.php/Pairs#pairs

Next:
http://wiki.roblox.com/index.php/Pairs#next
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
13 Aug 2013 11:57 PM
But, just use this code:

local function Length(Table)
local Len = 0
for k, v in next, Table do
Len = Len + 1
end
return Len
end
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
14 Aug 2013 12:07 AM
Did ArbiterOfDeath,

Just say what I thought he said?

Gemeric for (I would go research on RealWiki, why it is called Generic-for; who first proposed its inclusion of, inPairs, to the rarified lexicon of prepositions use by Derps to program their robots; and then recursively continue to research, 'til I reached the Invention of the wheel))).

but,

http://wiki.roblox.com/index.php/Generic_for

it is a special, good 'ol For loop used, a lot, in Tables-of-things, which just returns TWO 'Iterators (Is & Js): The Index (Tilte) of the List entry (1,2,3...), and the Contents of the particular entry (or pointer to it, or something. Read the Wiki...)

Used when u don't don't how big the list IS? Or when the list keeps changing, so u can't just stick a for I = 1 to 10 loop; or to be fancy.....
Or when u don't want to keep asking, "how big is #list"?

U should prolly always be using it, and get used to it. Taqbles r the way-to-go, and Some Frankenstien invented it.........

--Bri

Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
14 Aug 2013 12:11 AM
*Oh the important part....

It always loops the number of times as the number of things in some List,

Made for Tables....


Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
14 Aug 2013 12:16 AM
... What?
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
14 Aug 2013 12:21 AM
Lol,

I thought that I was explaining something in a folksy, understandable manner, and got a big "Rejected" for the Arbitor of Death. I will say my prays toniught.
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