This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
alfieq's profile picture

Repeating program

Started by alfieq, 25 March 2012 - 01:02 PM
alfieq #1
Posted 25 March 2012 - 03:02 PM
Hi,

I in the beginning of LUA script learning (sorry for bad sentences error as I was not in America or UK.). As I going to give away 1 code that useful for some sort of programs. I going to give a code called repeating (Some person called it loops) code pieces..

repeat
—-(this is where you can code anything after add repeat)—-
until nil (nil = infinite. )



You can experiment if you want because it just a little code pieces for beginner (like me) as this is a Program Library for small demonstration or small Info for scripts.

Here is my small demo in repeating (loops) program:

repeat
print "001010100001010100000101010101"
sleep(0.5)
print "000101010100010101010100010101"
sleep(0.5)
print "000101010001010100000101010000"
sleep(0.5)
print "000101010110000000101010100101"
sleep(0.5)
until nil


result:
001010100001010100000101010101
000101010100010101010100010101
000101010001010100000101010000
000101010110000000101010100101
001010100001010100000101010101
000101010100010101010100010101
000101010001010100000101010000
000101010110000000101010100101

all the way to infinite.. (be careful, it will not stopping until you break the program or use scripted floppy disk act like anti virus. (it also use like "SPAM VIRUS" as for mean hackers if they wanted to.)

signature:
-alfieq-
HTxL #2
Posted 25 March 2012 - 06:37 PM
what is the difference between that and "while" or "for"?…
looks to me like a normal "for" loop
alfieq #3
Posted 26 March 2012 - 08:59 AM
If you know English language, you already know :o/>/>

Here is my example from a script and from normal language:

script:
repeat
print "I like things"
until(10)

English:

Repeat this word "I like things" Until 10 times
Wolvan #4
Posted 26 March 2012 - 06:07 PM
If you know English language, you already know :o/>/>

Here is my example from a script and from normal language:

script:
repeat
print "I like things"
until(10)

English:

Repeat this word "I like things" Until 10 times
It should be like

a = 0
repeat
SOMETHING()
a + 1
until a == something
HTxL #5
Posted 27 March 2012 - 03:15 PM
If you know English language, you already know :o/>/>

Here is my example from a script and from normal language:

script:
repeat
print "I like things"
until(10)

English:

Repeat this word "I like things" Until 10 times
I still dont get it…

you can do

for i=0 ,10 do
print "i like things"
end

which will be exactly the same…