1 | print ( " Intermission..[10] " ) wait( 1 ) print ( " Intermission..[9] " ) wait( 1 ) print ( " Intermission..[8] " ) wait( 1 ) |
2 | print ( " Intermission..[7] " ) wait( 1 ) print ( " Intermission..[6] " ) wait( 1 ) print ( " Intermission..[5] " ) wait( 1 ) |
3 | print ( " Intermission..[4] " ) wait( 1 ) print ( " Intermission..[3] " ) wait( 1 ) print ( " Intermission..[2] " ) wait( 1 ) |
4 | print ( " Intermission..[1] " ) wait( 1 ) print ( " Intermission..[0] " ) wait( 1 ) |
You can shorten it by using a for-loop and concatinate the loop-index into the string.
There are of course many ways of solving this, but here's an example.
1 | for i = 10 , 0 , - 1 do -- starting at 10, goal is 0, we need to increment by -1 |
2 | print ( " Intermission..[" ..i.. "]" ) -- i is the index, the changing number in the loop |
3 | wait( 1 ) |
4 | end |
Rather than print that over and over again, I would suggest a loop.
1 | for I = 10 , 1 ,- 1 do --run the loop 10 times, starting from 10 and counting down to 1 |
2 | print ( "Intermission..[" .. tostring (I).. "] " ) --print stuff |
3 | wait( 1 ) --wait a second |
4 | end --end the loop |
This answer was provided by Chipio Industries