Advertisement
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 = 7
- local treeRows = 4
- local spacing = 1
- 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 + (spacing * 2)) do
- turtle.forward()
- end
- turtle.turnLeft()
- Offload()
- end
- function Offload()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=3, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- Restock()
- end
- function Restock()
- turtle.select(2)
- turtle.suck(64 - turtle.getItemCount(2))
- turtle.turnLeft()
- GrabFuel()
- end
- function GrabFuel()
- if turtle.getItemCount(1) < 16 then
- turtle.select(1)
- turtle.suckUp()
- end
- end
- function Refuel()
- if turtle.getFuelLevel(1) < 400 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- -- movement and execution
- 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()
- os.sleep(120)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement