|
| 28 Mar 2009 11:16 AM |
| What does [i] in a script mean? What is is used for? |
|
|
| Report Abuse |
|
|
cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 28 Mar 2009 11:17 AM |
I think your talking about a Index in a table.
local Table = {"Hai", "Lol", ":P"}
print( Table[1], Table[2], Table[3] ) |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2009 11:19 AM |
p = game.Players:GetChildren() for i = 1, #p do p[i].Character.Head:Remove() end
I am not sure, but I know that i is a variable.
p is the children of players.
i is a variable.
I think it does that loop the number of children there are.
Sorry if that doesn't help. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2009 11:21 AM |
It's usually used within a for loop to get each individual item of a table.
a=game.Players:GetChildren()
--now assume a = {game.Players.blobbyblob, game.Players.cymru72, game.Players.cupcakescankill}
for i = 1 to #a do --this will start up a loop that goes from 1 to #a. #a is the number of components in table "a" which is 3
print(a[i].Name) --this will loop through the table printing everyone's name
end --this ends the for loop.
Get it? |
|
|
| Report Abuse |
|
|
| |
|
cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 28 Mar 2009 11:24 AM |
local Table = {"Hai", "Lol", ":P"}
print( Table[1], Table[2], Table[3] )
print( table.concat(Table, " ") ) |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2009 11:26 AM |
| Yeah, DrAgon. I didn't know you were posting, though, because I spent a while writing that. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2009 11:27 AM |
Its the way the language gives the address of the data ina especific space, and its calculated in the next form:
new_address = address_expression + (interger(In this case i) * size_of_base_type)
addresses in a table are next to each other so, in the case the values in the table are interger (numbers with no decimal) in a 32 bit system (Almost all of the actual) would be lets say the first element of the table has an addres og 0x1000 then the next element would be? lets use the formula new_address = address_expression + (interger(In this case i) * size_of_base_type)
new_address = 1000 + (i which would be 1 * 4) new_adress = 1004 and the computer will access to the next value in the table... |
|
|
| Report Abuse |
|
|
cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 28 Mar 2009 11:28 AM |
Heres a small example:
local Table = {"Hai", "LOOL", "XD", ":P"}
for Index, Data in pairs(Table) do print(Data, Index) end
Data will return the string value inside the table, Index will return a numerical value. |
|
|
| Report Abuse |
|
|