Posted 02 May 2013 - 07:33 PM
Hi i am trying to get my turtle to remember where it left off after coming "home" to empty.
basicly what the turtle is doing now is strip mining forward coming home then making tunnels where he has mined (so branch mining)
this part works fine but my problem is i want it to kind of quarry its way down so after it is done with strip mine and the tunnels it will come home go down and restart the process but the problem is that when i call him home after he is down a layer the goes back to the layer where he started and then doesnt remember what layer he was on so he will begin to dig air instead of going down more layers.
edit also i need it to remember its place when it empties too because when he gets down a couple a layers and his inventory gets full he will go back to the chest and continue his strip mine from there instead if going back down
basicly what the turtle is doing now is strip mining forward coming home then making tunnels where he has mined (so branch mining)
this part works fine but my problem is i want it to kind of quarry its way down so after it is done with strip mine and the tunnels it will come home go down and restart the process but the problem is that when i call him home after he is down a layer the goes back to the layer where he started and then doesnt remember what layer he was on so he will begin to dig air instead of going down more layers.
tdist = 0
dist = 0
depth = 0
local tArgs = {...}
local times = tArgs[1] and tonumber(tArgs[1]) or 1
function down()
turtle.turnRight()
turtle.turnRight()
turtle.digDown()
turtle.down()
depth = depth + 1
turtle.digDown()
turtle.down()
depth = depth + 1
end
function turn()
turtle.turnLeft()
turtle.turnLeft()
end
function tunnel()
go()
go()
dist = dist + 2
turtle.turnLeft()
for i=1,times do
go()
tdist = tdist + 1
turtle.dig()
turtle.digUp()
turtle.digDown()
end
end
function tunnelhome()
turn()
while tdist > 0 do
go()
tdist = tdist - 1
end
turtle.turnLeft()
end
function go()
while not turtle.forward() do
turtle.dig()
end
sleep(0.8)
end
function dig()
turtle.dig()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.dig()
go()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
go()
turtle.dig()
go()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
go()
turtle.turnLeft()
go()
dist = dist + 1
end
function empty()
if turtle.getItemCount(16) > 15 then
turtle.turnLeft()
turtle.turnLeft()
while dist > 0 do
go()
end
select(1)
for i=1,16 do
select(i)
turtle.drop()
end
end
end
function home()
print(dist)
turtle.turnLeft()
turtle.turnLeft()
while dist > 0 do
go()
dist = dist - 1
print(dist)
end
while depth > 0 do
turtle.digUp()
turtle.up()
depth = depth - 1
end
for i=1,16 do
turtle.select(i)
turtle.drop()
end
end
function all()
for i=1,times do
for i=1,times do
dig()
empty()
end
home()
turtle.turnLeft()
turtle.turnLeft()
for i=1,times do
tunnel()
tunnelhome()
end
home()
down()
end
end
all()
edit also i need it to remember its place when it empties too because when he gets down a couple a layers and his inventory gets full he will go back to the chest and continue his strip mine from there instead if going back down