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

miningturtle stop going forward

Started by swedenick, 06 January 2014 - 01:03 PM
swedenick #1
Posted 06 January 2014 - 02:03 PM
Hello

I have been playng aroud with Direwolf20 fead the beast and mining turtles.
but they stop going forward för some reason…

I have a simple program and I had the turtle fail when I used 2 different while loops with os.sleep(0.5) in them…
when I added the RED line of code the turtle stopped going forward… and I cant get it fixed, all turtles stop going forward,
excavate still works though.


program: (it digs a 3 high corridor and places torches when it works.)

local run = 0

term.write("length: ")
run = read()

for i = 0, run do

while turtle.detect() do
turtle.dig()
os.sleep(0.5)
end
turtle.forward()

while turtle.detectUp() do
turtle.digUp()
os.sleep(0.5)
end

turtle.digDown()

if(i %6) == 1 then
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.select(16)
turtle.placeUp()
turtle.turnLeft()
turtle.forward()
end

end

turtle.turnLeft()
turtle.turnLeft()
for i = 0, run do
turtle.forward()
end
Agoldfish #2
Posted 08 January 2014 - 12:25 PM
Spoiler<p>It's not os.sleep. It is just sleep.<br>That is what I see, though there is probably more.<br><br>Here is your code, I fixed the problem I saw.<br>
<br>local run = 0<br>term.write("length: ")<br>run = read()<br>for i = 0, run do<br>while turtle.detect() do<br>turtle.dig()<br>os.sleep(0.5)<br>end<br>turtle.forward()<br>while turtle.detectUp() do<br>turtle.digUp()<br>sleep(0.5)<br>end<br>turtle.digDown()<br>if(i %6) == 1 then<br>turtle.turnLeft()<br>turtle.turnLeft()<br>turtle.forward()<br>turtle.turnLeft()<br>turtle.select(16)<br>turtle.placeUp()<br>turtle.turnLeft()<br>turtle.forward()<br>end<br>end<br>turtle.turnLeft()<br>turtle.turnLeft()<br>for i = 0, run do<br>turtle.forward()<br>end<br>
<br></p>
I did a horrible job responding to this, the OP is in the spoiler, but do not look at it. It is horrible.
Edited on 08 January 2014 - 07:04 PM
CometWolf #3
Posted 08 January 2014 - 06:23 PM
os.sleep and sleep both work, but there is however no reason to use sleep in a loop with a turtle action. Using turtle.back() instead of turning around 2 times and going back would probably be a good idea. Aside from that, there's nothing immediately wrong about this code. You sure you got fuel? Also what the hell can you divide 6 by to get one left over? wouldn't i%(number you want) == 0 be better?