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: Can someone explain to me IN HIGH DETAIL.

Previous Thread :: Next Thread 
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Aug 2013 11:49 AM
In high detail can someone explain this to me? I know what it does. Just eplain EVERYTHING.
Dont put: It clones everything it workpace.
What I need to know is WHY are THERE certain THINGs there such as the:
for, _, ,, v, ()).



for _,v in pairs(game.Workspace()) do
v:clone()
end
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
06 Aug 2013 12:09 PM
Ah, another detail-oriented! You are as I, because I really need a lot of detail to understand things.

First of all, this will not work. This will work:

for _,v in pairs(Workspace:GetChildren()) do
v:clone() --.Parent = Workspace
end

Now, I shall explain line-by-line.
pairs is an iterative function to build on with the for loop. A 'for loop' is a loop that will run through a certain set of data until it reaches a stopping point.
When we say for _,v in pairs, we are defining a loop, and telling it run through everything we give it, whilst defining a key and a value.
The _ variable will tell us which INDEX we are at, and the v variable tells the VALUE at that index.
pairs is no more than a function. The first and only parameter of pairs is the table that it needs to run through.

for _,v in pairs(Workspace:GetChildren()) do
The first word identifies a for loop. The next term (_,v) is defining the two variables by which we iterate, where _ is the index and v is the value. Workspace:GetChildren() returns a table of all objects inside of the Workspace. The final constructor, 'do', opens the for loop.

v:clone()
This copies all userdata into nothing so far. If we were to set it as a variable, or set its Parent, it would be useful.

end
This ends the for loop.

The best way to see what I mean by the key/value relationship is to run this program:

t = {'Alpha', 'Beta', 'Gamma', 'Delta', 'Nu', 'Pi', 'Phi'}
for i,v in pairs(t) do
print(v..' is the '..tostring(i)..'-index value in the table.')
end

table.sort(t)
for i,v in pairs(t) do
print('After sorting the table, '..v..' is the '..tostring(i)..'-index value in the table.')
end
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Aug 2013 12:20 PM
Thank you.
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