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

Troubles with Custom tunneling program

Started by enterprise0709, 26 December 2012 - 09:55 AM
enterprise0709 #1
Posted 26 December 2012 - 10:55 AM
Hallo there

I'm having problems with making a "gravel proof" custom tunneling program.
With this program i try to get a turtle to dig a 3x3 turtle like this:

XXX
XTX
XXX

T is turtle's position
X is a block
O is a empty grid

turtle turns left and brakes the block and moves forward just fine. Also detects gravel that falls down and clears it

XXX
TOX
XXX

tunnel then brakes block above it and moves up

TXX
OOX
XXX

turtle then makes a 180 degrees turn with 2 turn left comands

turtle brakes the block above it's starting postion

TOX
OOX
XXX

here starts the problem
the turtle brakes the block above it's starting position but does not move there!
T !X
OOX
XXX

(! being the block the turtle does not move to)

I've been doing some tests myself, and when this 3x3 grid is empty, the turtle completes the circle just fine

Here's the code i suspect the turtle has been geting stuck on (starting from the point it moves to the uper left square)

if turtle.up() == false then
repeat
turtle.digUp()
sleep(0,25)
until turtle.up() == true
end (turtle completes this step just fine)

turtle.turnLeft()
turtle.turnLeft() (turtle made a 180 degrees turn)

if turtle.forward() == false then
repeat
turtle.dig()
sleep(0,25)
until turtle.forward() == true
end this is the part the turtle gets stuck)

turtle doesn't move forward as it should, it does brake any block i place in front of it. As stated before, the turtle moves forward if there is no block there in the first place.

I hope you fokes can help me out with this issue

thanks already, and a merry christmas!

Enterprise0709

Edit: Excuse me, that turtle.up was a typo on my part it should be .forward… as it is in the actual program, and does not execute
remiX #2
Posted 26 December 2012 - 11:36 AM
well it repeats turtle.dig() until it goes up, but it never goes up because you have no turtle.up()
ChunLing #3
Posted 26 December 2012 - 06:21 PM
That is to say, you should test for turtle.forward, but you're testing for turtle.up instead.

A side note, you don't need the initial conditional and the extra comparisons.
while not turtle.up() do
    turtle.digUp()
end
turtle.turnLeft()
turtle.turnLeft()
while not turtle.forward() do
    turtle.dig()
end
It's not necessarily true in all cases, but in this particular case you don't need the sleeps either, since the movements will fail as long as gravel is falling in front/on top of the turtle.
enterprise0709 #4
Posted 26 December 2012 - 10:55 PM
That is to say, you should test for turtle.forward, but you're testing for turtle.up instead.

A side note, you don't need the initial conditional and the extra comparisons.
while not turtle.up() do
	turtle.digUp()
end
turtle.turnLeft()
turtle.turnLeft()
while not turtle.forward() do
	turtle.dig()
end
It's not necessarily true in all cases, but in this particular case you don't need the sleeps either, since the movements will fail as long as gravel is falling in front/on top of the turtle.

Thanks Chung! that did the trick! That turtle.up() was a typo on my part, that was supose to be turtle.forward(), as it used to be in the program.