Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local treeSize = 2
- local treeCount = 2
- local treeDistance = 4
- local function refuel()
- local currentSlot = turtle.getSelectedSlot()
- turtle.select(1)
- if not turtle.refuel(1) then
- print("Waiting for fuel!")
- while not turtle.refuel(1) do
- end
- end
- turtle.select(currentSlot)
- end
- local function moveForward()
- refuel()
- return turtle.forward()
- end
- local function moveUp()
- refuel()
- turtle.up()
- end
- local function moveDown()
- refuel()
- turtle.down()
- end
- local function moveBack()
- refuel()
- turtle.back()
- end
- local function moveForwardForce()
- while not moveForward() do
- turtle.dig()
- end
- end
- local function harvestTree()
- print("Harvesting tree")
- turtle.dig()
- turtle.forward()
- turtle.select(3)
- if treeSize == 1 then
- print("Tree Size 1")
- local treeHeight = 1
- while turtle.compareUp() do
- turtle.digUp()
- moveUp()
- treeHeight = treeHeight + 1
- end
- print("Tree Height:",treeHeight)
- while turtle.detectDown() == false do
- moveDown()
- end
- turtle.back()
- turtle.select(2)
- turtle.place()
- elseif treeSize == 2 then
- while turtle.compareUp() do
- turtle.dig()
- turtle.digUp()
- moveUp()
- end
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- moveForward()
- turtle.turnLeft()
- while turtle.compareDown() do
- turtle.dig()
- turtle.digDown()
- moveDown()
- end
- turtle.dig()
- turtle.select(2)
- turtle.place()
- turtle.turnLeft()
- moveForward()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.place()
- turtle.turnLeft()
- moveBack()
- turtle.place()
- end
- end
- local function doTreeIteration()
- turtle.turnLeft()
- turtle.select(2)
- if turtle.compare() then
- print("Tree not ready.")
- end
- turtle.select(3)
- if turtle.compare() then
- print("Harvesting tree")
- harvestTree()
- else
- error("Unexpected tree grew!")
- end
- turtle.turnRight()
- end
- local function doInventoryManagement()
- turtle.turnLeft()
- turtle.select(1)
- turtle.suck(turtle.getItemSpace())
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(2)
- turtle.suck(turtle.getItemSpace())
- turtle.turnLeft()
- for i=4,16,1 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- local function runPath()
- moveForwardForce()
- doTreeIteration()
- for i=2,treeCount,1 do
- for j=1,treeDistance,1 do
- moveForwardForce()
- end
- doTreeIteration()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=2,treeCount,1 do
- for j=1,treeDistance,1 do
- moveForwardForce()
- end
- end
- moveForwardForce()
- turtle.turnRight()
- turtle.turnRight()
- doInventoryManagement()
- end
- runPath()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement