ThePixel
|
  |
| Joined: 15 May 2010 |
| Total Posts: 225 |
|
|
| 29 Jul 2011 07:28 PM |
I'm slowly learning Lua, mainly by editing scripts. Many times I see this, and don't know exactly what it does. Is it a for loop..?
for i =1,2 do
Thats just a example of one of them, what does it do, whats it used for and what are some cases it could be used in. Are there any lines similar to this I should know about?
If I had to guess, it only runs the script is i = 1 or 2? I don't see how that would be used much though. |
|
|
| Report Abuse |
|
|
Cliff86
|
  |
| Joined: 01 Mar 2008 |
| Total Posts: 216 |
|
|
| 29 Jul 2011 07:30 PM |
repeats the code underneath from 1 to 2 increasing by 1 each time :P
the first time i = 1 the second time i = 2 |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2011 07:32 PM |
Basically. There are things with x = game.Workspace:GetChildren() "for i=1,#x do" as well, but you just keep learning:P
~COD~ |
|
|
| Report Abuse |
|
|
5943539
|
  |
| Joined: 05 Jan 2010 |
| Total Posts: 810 |
|
|
| 29 Jul 2011 07:33 PM |
For loops run each time you specify, when i is greater than or equal to the second number.
for i=0,2 do
Runs the following 3 times until the end, with i being 0 the first time, 1 the second, and 3 the third.
for i=1,2 do
Runs it twice: i is 1 the first time and 2 the second.
for i=0,2,.5 do
Runs it five times. i is 0,.5,1,1.5,2 each time it runs. |
|
|
| Report Abuse |
|
|
ThePixel
|
  |
| Joined: 15 May 2010 |
| Total Posts: 225 |
|
|
| 29 Jul 2011 08:02 PM |
| Thank you, how common are these, I don't see these being used in to many situations. |
|
|
| Report Abuse |
|
|
| |
|