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

repeat lop

Started by Vardrom, 16 March 2012 - 01:35 AM
Vardrom #1
Posted 16 March 2012 - 02:35 AM
ok what ever i do thsi loop wont work it will go thro only once even if i set the input to 100000000.

hers my cod:

counter = 1

print ("How long do you wont the tunnel to be")

input = read()
repeat

turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.down()
turtle.down()

counter = counter + 1

until counter < input
Luanub #2
Posted 16 March 2012 - 02:54 AM
You're telling it to stop when counter is less then the input, so if you input anything higher then 1 the condition exists and the loop stops. You probably are looking for something more like..


repeat
until count == input or..
until count >= input

or try a while loop


while count ~= input do
end

Both basically do the same thing.
Vardrom #3
Posted 16 March 2012 - 03:03 AM
You're telling it to stop when counter is less then the input, so if you input anything higher then 1 the condition exists and the loop stops. You probably are looking for something more like..


repeat
until count == input or..
until count >= input

or try a while loop


while count ~= input do
end

Both basically do the same thing.
that did not work but i fond out the problum i had to make input a rell number not a holder so i did input = input +0