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

[SVOLED] How to get this looping as much as i want?

Started by Bamse5b, 16 October 2012 - 03:30 PM
Bamse5b #1
Posted 16 October 2012 - 05:30 PM
Hey, i just wonder how to get my code here to do like ask me: "How long tunnel: "? I tryed but this is the code i made (think its made before) because ima newbi thats why i need help


if turtle.detect() then
turtle.digUp()
turtle.dig()
turtle.up()
turtle.dig()
turtle.down()
turtle.forward()
else
turtle.forward()
end
sjele #2
Posted 16 October 2012 - 05:32 PM

write("How long tunnel: ")
input = tonumber(read())

for i = 1, input do
--code to repeat
end
Bamse5b #3
Posted 16 October 2012 - 05:33 PM
Thanks!
Lyqyd #4
Posted 16 October 2012 - 05:35 PM

write("Tunnel Length: ")
local len = tonumber(read())
for i=1,len do --this makes it loop 'len' times, using whatever number you entered
--your existing code here
end