Posted 05 June 2013 - 01:46 PM
Hi, this is my attempt to make a customized turtle digging code. I'm stumped on how to fix its funky movements. Upon digging to the next level, it digs 1 block over the right amount, and upon its second level down it turns in the completely wrong direction. Here is my code:
Thanks for any help
term.clear()
term.setCursorPos(1, 1)
function status(a, B)/> return print("Block Number X, Z, Y: "), print(k..", "..j..", "..i) end
while true do
print("Length: ")
input = read()
if tonumber(input) then
x = tonumber(input)
break
else
print("Input must be a number!")
end
end
while true do
print("Width: ")
input = read()
if tonumber(input) then
z = tonumber(input)
break
else
print("Input must be a number!")
end
end
while true do
print("Depth: ")
input = read()
if tonumber(input) then
y = tonumber(input)
break
else
print("Input must be a number!")
end
end
i = 0
j = 0
k = 0
depth = y
length = x
width = z
right = true
direction = true
pattern = true
while i < y do
while j < z do
while k < x do
turtle.dig()
turtle.forward()
status()
k = k + 1
end
if right then
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
right = false
else
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
right = true
end
k = 0
j = j + 1
end
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
while k < x do
turtle.dig()
turtle.forward()
k = k + 1
end
k = 0
turtle.turnLeft()
turtle.digDown()
turtle.down()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
right = true
j = 0
if pattern then
x = width
z = length
pattern = false
else
x = length
z = width
pattern = true
end
i = i + 1
end
turtle.up()
print("Finished!")
Thanks for any help