1 posts
Posted 15 April 2012 - 06:19 PM
What I want to do is loop this program so I don't have to keep retyping it but I can't figure out how.
I want to loop this.
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
So it will end up making a staircase to bedrock.
Thanks in advanced
EDIT: figured it out so you can delete this.
63 posts
Location
Amsterdam
Posted 15 April 2012 - 06:26 PM
You could use
while true do
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end
but this will go on for ever so i recommend using it like this
x = 0
while x < 20 do
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end
This will repeat the code for 20 times.
474 posts
Posted 15 April 2012 - 06:27 PM
IGNORE
474 posts
Posted 15 April 2012 - 06:28 PM
Spoiler
You could use
while true do
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end
but this will go on for ever so i recommend using it like this
x = 0
while x < 20 do
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end
This will repeat the code for 20 times.
If you want to do it a certain amount of times, don't use that, use a for loop:
local amount = 5 -- Change 5 to how many times you want to loop it
for DoNotChangeThis=1,amount do
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end
Code for doing it forever:
while true do
sleep(0)
turtle.digDown()
turtle.down()
turtle.dig()
turtle.forward()
turtle.dig()
end