Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Kap's Lumberjack Turtle ver 1.0, 01/11/18
- local tArgs = {...}
- local runs = tonumber(tArgs[1])
- local trees = 8
- local treeRows = 6
- local spacing = 1
- local furnaceCount = 11
- local direction = true
- local height = 1
- local maxHeight = 5
- function ChopTree()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- Plant()
- while turtle.detectUp() do
- if height >= maxHeight then break end
- turtle.digUp()
- turtle.up()
- height = height + 1
- os.sleep(1)
- end
- while not turtle.detectDown() do
- turtle.down()
- height = height - 1
- end
- end
- function Plant()
- turtle.select(2)
- turtle.placeDown()
- end
- function Return()
- direction = true
- turtle.turnLeft()
- for i=1, (treeRows + (treeRows*spacing)-1) do
- turtle.forward()
- end
- turtle.turnLeft()
- OffloadWood()
- end
- function OffloadWood()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=3, 16 do
- turtle.select(i)
- turtle.drop()
- end
- Restock()
- end
- function Restock()
- turtle.down()
- turtle.select(2)
- if turtle.getItemCount(2) < 16 then
- turtle.suck(16)
- end
- GrabFuel()
- end
- function GrabFuel()
- turtle.select(1)
- turtle.suckDown(64 - turtle.getItemCount(1))
- turtle.up()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function Refuel()
- if turtle.getFuelLevel(1) < 400 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function FillFurnaces()
- -- pick up wood
- turtle.turnLeft()
- turtle.turnLeft()
- for i=3, 16 do
- turtle.select(i)
- turtle.suck()
- end
- --move to furnaces
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.up()
- turtle.forward()
- turtle.turnRight()
- -- Fill all furnaces
- for i=1, furnaceCount do
- for j=3, 16 do
- turtle.select(j)
- if turtle.dropDown() then break end
- end
- if i < furnaceCount then turtle.forward() end
- end
- -- move back and drop off leftover wood
- turtle.turnRight()
- turtle.turnRight()
- for i=1, (furnaceCount - 1) do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.down()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i=3, 16 do
- turtle.select(i)
- turtle.drop()
- end
- -- fill furnaces with charcoal
- turtle.down()
- turtle.turnRight()
- for i=3, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- for i=1,furnaceCount do
- for j=3, 16 do
- turtle.select(j)
- if turtle.dropUp(8) then break end
- end
- if i < furnaceCount then
- turtle.dig()
- turtle.forward()
- end
- end
- --move back, drop remainder coal off.
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i=1, 11 do
- turtle.forward()
- end
- for i=3, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- -- now get charcoal from furnaces
- turtle.back()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- -- fetch from all furnaces
- for i=1, furnaceCount do
- for j=3, 16 do
- turtle.suckUp()
- end
- if i < furnaceCount then
- turtle.dig()
- turtle.forward()
- end
- end
- -- move back and drop off charcoal
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i=1, furnaceCount do
- turtle.forward()
- end
- for i=3, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.up()
- turtle.turnLeft()
- end
- function FetchDrops()
- -- todo
- end
- -- movement and execution
- turtle.turnLeft()
- turtle.turnLeft()
- for x=1, runs do
- for i=1, treeRows do
- Refuel()
- for j=1, trees do
- if turtle.detect() and not turtle.detectDown() then
- ChopTree()
- turtle.dig()
- turtle.forward()
- else
- turtle.forward()
- Plant()
- turtle.dig()
- turtle.forward()
- end
- end
- if i == treeRows then break end
- if direction then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- direction = false
- else
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- direction = true
- end
- end
- Return()
- if x % 3 == 0 then
- FillFurnaces()
- end
- --if x % 10 == 0 then
- -- FetchDrops()
- --end
- os.sleep(5)
- end
Add Comment
Please, Sign In to add comment