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

[lua][question] Looping and entire program

Started by mister_s, 10 July 2012 - 08:12 PM
mister_s #1
Posted 10 July 2012 - 10:12 PM
I just want my program to loop to the top of the script when it's done. How would I do that?
MysticT #2
Posted 10 July 2012 - 10:17 PM
Use a loop. To make an infinite loop, use:

while true do
  -- your code
end
To repeat for a given number of times:

for i = 1, <Times> do
  -- your code
end
There's more you can read about loops, the lua manual is a good place to look.
BigSHinyToys #3
Posted 10 July 2012 - 10:18 PM
This is the a simple loop

while true do
    os.pullEvent() -- this is needed to stop program crash
    print("hello World")
end