Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- direction="left"
- home=true
- function sweep()
- for i = 1, 7 do
- turtle.dig()
- turtle.up()
- end
- turtle.dig()
- for i = 1, 8 do
- turtle.down()
- end
- end
- function rotate()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function harvest()
- for i = 1, 4 do
- sweep()
- rotate()
- end
- end
- function dumpItems()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function toggleDirection()
- if direction=="left" then
- print("Direction set to right")
- direction="right"
- else
- print("Direction set to left")
- direction="left"
- end
- end
- function turn()
- if direction=="left" then
- print("turn left")
- turtle.turnLeft()
- else
- print("turn right")
- turtle.turnRight()
- end
- end
- function turnBack()
- if direction == "left" then
- print("turnBack right")
- turtle.turnRight()
- else
- print("turnBack left")
- turtle.turnLeft()
- end
- end
- function goHome()
- turn()
- turn()
- while turtle.forward() do
- end
- if direction=="left" then
- turtle.turnLeft()
- while turtle.forward() do
- end
- turtle.turnRight()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- dumpItems()
- turtle.turnLeft()
- print("Sleeping for 5min to recharge")
- sleep(300)
- end
- function goEdge()
- print("Going to edge of wall")
- while turtle.forward() do
- end
- end
- function goDown()
- print("Going down")
- while turtle.down() do
- end
- end
- function resume()
- goDown()
- if turtle.detect() then
- turtle.turnRight()
- end
- goEdge()
- turtle.turnRight()
- goEdge()
- while not checkStartCorner() do
- goNextCorner()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- dumpItems()
- turtle.turnLeft()
- print("Sleeping for 5min to recharge")
- sleep(300)
- end
- function checkStartCorner()
- print("Checking for start corner")
- turtle.up()
- if turtle.detect() then
- turtle.down()
- return true
- end
- turtle.down()
- return false
- end
- function goNextCorner()
- print("Going to next corner")
- turtle.turnRight()
- goEdge()
- end
- function nextTree()
- print("Finding next tree")
- if home then
- print("Home now")
- turtle.forward()
- home=false
- return true
- else
- turn()
- turtle.forward()
- if not turtle.forward() then
- print("Reached end of row, finding new row")
- turnBack()
- turtle.forward()
- turtle.forward()
- if turtle.detect()then
- print("Reached last row, going home")
- goHome()
- direction="left"
- home=true
- return false
- end
- turtle.down()
- turnBack()
- turtle.forward()
- turn()
- toggleDirection()
- else
- turnBack()
- end
- return true
- end
- end
- if not turtle.detectUp() then
- resume()
- end
- while true do
- print("Starting Tapping Route...")
- while nextTree() do
- harvest()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment