Posted 10 December 2012 - 08:42 AM
Ok so, I have codded a quarry program and tried it out, it digs the first row fine then moves itself into position for the next one, but then it turns itself back around, so it is facing the opposite way it should be facing!
Code:
Code:
tlor=true --True = right, False = false
function digRow(l) --Dig a row
for i=1,(l-1) do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
end
end
function digLayer(l)
for i=1,l do
digRow(l)
if tlor == true then
turtle.turnRight()
else
turtle.turnLeft()
end
if turtle.detect() then turtle.dig() end
turtle.forward()
if tlor == true then
turtle.turnRight()
else
turtle.turnLeft()
end
sleep(1)
if tlor == true then
tlor = false
return true
else
tlor = true
return true
end
print("Layer "..i.." has been dug!")
end
end
function Quarry(len,heh)
for d=1,(heh+1) do
digLayer(len)
turtle.turnLeft()
turtle.turnLeft()
if turtle.detectDown() then
turtle.digDown()
end
turtle.down()
end
turtle.turnLeft()
turtle.turnLeft()
for l=1,(heh+1) do
turtle.up()
end
return true
end
tArgs = { ... }
Arg1 = shell.resolve(tArgs[1])
Arg2 = shell.resolve(tArgs[2])
if #tArgs == 2 then
tonumber(Arg1)
tonumber(Arg2)
Quarry(tArgs[1],tArgs[2])
else
print("Usage: tQuarry <length> <height>")
end