|
| 29 Sep 2012 10:40 PM |
I want to make it so that you pick a size. I made my example 5.
It makes the size negative: -5 then it is supposed to print it until positive 5 then back to -5 over and over:
>-5 >-4 >-3 >-2 >-1 >0 >1 >2 >3 >4 >5 >4 >3 >2 >1 >0 >-1 >-2 >-3 >-4 >-5...
and so on. But, my script doesn't work. It stops at positive six:
local size=5 local size=size+1 local start=(-size) while wait() do for i=1,start*(-2) do start=start+1 print(start) wait(0.5) end for i=1,start*(-2) do start=start-1 print(start) wait(0.5) end end |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 29 Sep 2012 10:44 PM |
This is better ;)
size = -5 repeat print(size) size = size + 1 until size >=5 for i = 5,-5,-1 do print(i) end
|
|
|
| Report Abuse |
|
|
|
| 29 Sep 2012 10:48 PM |
Thanks miz, that works. But it doesn't do it over and over :[ But that's simple, I think i can fix |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 29 Sep 2012 10:50 PM |
| Add an infinite loop and there you go. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2012 11:26 PM |
Ooh! Lemme try!
while true do wait(0.01) for i = -5,5,1 do print(i) wait(0.01) end end
Tell me if that works; I just pulled it out of thin air. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
| |
|
|
| 29 Sep 2012 11:29 PM |
Wait a minute. Nevermind.
while true do wait(0.01) for i = -5,5,1 do print(i) wait(0.01) end for i = 5,-5,-1 do print(i) wait(0.01) end end
I really should open Studio and test this before looking like a buffoon, but Studio hates me today...
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 29 Sep 2012 11:31 PM |
Nope.
(Hint *look at for loop*)(: |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2012 11:35 PM |
| @miz - There's nothing wrong with his second one. |
|
|
| Report Abuse |
|
|
omzig
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 578 |
|
|
| 29 Sep 2012 11:35 PM |
| Also that oculd lag the game if you had such a small wait time with while true do... |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 29 Sep 2012 11:37 PM |
| Oh yeah, I looked at the for loop wrong ;/ |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2012 11:39 PM |
| Yeah, I know what you did; you mixed up the increment. :P |
|
|
| Report Abuse |
|
|