|
| 11 Jul 2016 02:59 PM |
The wiki didn't help me that much.
Frugal Kitchens & Cabinets™; "Life happens here!" https://www.youtube.com/watch?v=WM9Qi15g6V0 |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 03:00 PM |
Pairs is a stateless iterator, and it is used to iterate over dictionaries. That's about it.
for Key, Value in pairs(Dictionary) do
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 03:01 PM |
It's pretty much the same as this,
for i,v in pairs do -- script end
I is the place value of the object V is the object in the thing, so...
(THIS SCRIPT WONT WORK, JUST AN EXAMPLE FOR CONCEPT)
local array = {"object1", "object2", game.Workspace.Name}
for i,v in pairs array do print(i) print(v) end
Output: 1 object1 2 object2 3 workspace
#code function brag() print("R$686") end |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 03:01 PM |
Ah ok. Thanks
Frugal Kitchens & Cabinets™; "Life happens here!" https://www.youtube.com/watch?v=WM9Qi15g6V0 |
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 11 Jul 2016 03:02 PM |
for index,value in pairs(workspace:GetChildren()) do --stuff end
pairs takes an index, which, in the table, is the number of the value (like, if the workspace is iterated through and "Baseplate" is the first then index=1) and a value, which is the actual instance/value of the table (if "Baseplate" is first then v.Name=="Baseplate")
It iterates through the table given in parenthesis.
Try to run this code in the command bar:
for i,v in pairs(workspace:GetChildren()) do print(i,v) end
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 04:01 PM |
Non-technical explanation: for key, value in pairs(tbl) do will iterate over all key-value pairs in the table 'tbl'
Technical explanation: docs.google dot com/document/d/1KlrlNYNfVKyvTbmJBoVODOqMJF-wTn_JbGUEm0G6RIM scroll down to "Generic For Loop" |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 11 Jul 2016 04:19 PM |
for i,v in next, tab do print(i,v) end
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 04:21 PM |
@Cntkillme
I'm looking to learn more about the technical side of Lua because of your posts here, you're able to articulate in ways many people here can't because they don't know the terminology.
Do you have any other resources like that?
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 04:31 PM |
Here's another one: docs.google dot com/document/d/1A1SBjRqFKFxaw7_RnsI96CKzBCcAOkuDPOTG8DIZywA |
|
|
| Report Abuse |
|
|