piepiedogJoin Date: 2008-11-16 Post Count: 1326 |
I know while true do repeats forever, but I forgot how to repeat something a certain number of times. Isnt it something like while (1,10) do? |
|
SpectrumwJoin Date: 2009-08-04 Post Count: 13510 |
for i = 1, 10 do
-- Your stuff
end |
|
piepiedogJoin Date: 2008-11-16 Post Count: 1326 |
had a feeling it was for, thanks! |
|
|
arundelJoin Date: 2008-04-21 Post Count: 5762 |
Inefficient way:
a = 0
repeat
a = a + 1
until a == 10 |
|
SpectrumwJoin Date: 2009-08-04 Post Count: 13510 |
Your way is way more inefficient. |
|
|
I hate how people think that while loops always have to be 'while true do'. while loops are basically backwards repeat loops, and vice versa. |
|
KurokiJoin Date: 2009-12-27 Post Count: 18058 |
@Arundel
i believe thats just for numbers
he wants to repeat an arithmetic X times |
|
arundelJoin Date: 2008-04-21 Post Count: 5762 |
"i believe thats just for numbers"
Does that sentence make sence?
It's a loop. You can repeat anything. >.>
All your code should be inbetween 'repeat' and 'until'
if you want to repeat your code. |
|
|
i=0
while true do
if i < 10 then
i = i + 1
elseif i >= 10 then
break
end
wait(1)
end
--"Terrible"! way too do it. |
|
arundelJoin Date: 2008-04-21 Post Count: 5762 |
Then why don't you just do this? :P
i = 0
while i < 10 do
i = i + 1
wait()
end |
|
myrco919Join Date: 2009-06-12 Post Count: 13241 |
[ Content Deleted ] |
|
myrco919Join Date: 2009-06-12 Post Count: 13241 |
[ Content Deleted ] |
|
myrco919Join Date: 2009-06-12 Post Count: 13241 |
[ Content Deleted ] |
|
|
If u wan't it to do something 10 times then use this:
if i = 1, 10 do |
|
arundelJoin Date: 2008-04-21 Post Count: 5762 |
@Cool, that won't work. |
|
|
arundelJoin Date: 2008-04-21 Post Count: 5762 |
You used an if statement, and I think you ment a "for" loop. |
|
myrco919Join Date: 2009-06-12 Post Count: 13241 |
[ Content Deleted ] |
|
|