Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1, 1)
- local fuel_requirement = 120
- local current_direction = 0
- local function checkFuel()
- if turtle.getItemCount(1) <= 1 then
- if turtle.getFuelLevel() < fuel_requirement then
- print("Fuel is urgently required in slot 1.")
- elseif turtle.getFuelLevel() < (fuel_requirement * 2) then
- print("Fuel is required soon in slot 1.")
- end
- end
- repeat
- if (turtle.getItemCount(1) > 1) then
- turtle.select(1)
- turtle.refuel(1)
- end
- sleep(0.5)
- until turtle.getFuelLevel() >= fuel_requirement
- end
- local function turnToFace(direction)
- if direction == 0 then
- if current_direction == 1 then
- turtle.turnLeft()
- elseif current_direction == 2 then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif current_direction == 3 then
- turtle.turnRight()
- end
- current_direction = 0
- elseif direction == 1 then
- if current_direction == 2 then
- turtle.turnLeft()
- elseif current_direction == 3 then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif current_direction == 0 then
- turtle.turnRight()
- end
- current_direction = 1
- elseif direction == 2 then
- if current_direction == 3 then
- turtle.turnLeft()
- elseif current_direction == 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif current_direction == 1 then
- turtle.turnRight()
- end
- current_direction = 2
- elseif direction == 3 then
- if current_direction == 0 then
- turtle.turnLeft()
- elseif current_direction == 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif current_direction == 2 then
- turtle.turnRight()
- end
- current_direction = 3
- end
- end
- local function waitForLog()
- success, data = turtle.inspect()
- print("Waiting for tree...")
- repeat
- sleep(1)
- success, data = turtle.inspect()
- until (data.name == "minecraft:spruce_log")
- print("Chopping tree...")
- end
- local function supplySaplings()
- -- get saplings from chest
- if turtle.getItemCount(2) < 4 then
- turnToFace(1)
- turtle.select(2)
- while turtle.getItemCount(2) < 4 do
- turtle.suck(1)
- sleep(1)
- end
- turtle.select(1)
- turnToFace(0)
- end
- end
- local function giantSpruce()
- turtle.select(1)
- checkFuel()
- supplySaplings()
- waitForLog()
- turtle.dig()
- turtle.forward()
- local success, data = turtle.inspectUp()
- while (success) do
- turtle.dig() -- dig in front
- turnToFace(1) -- turn right
- turtle.dig() -- dig in front (the right)
- turnToFace(0) -- turn left
- turtle.digUp()
- turtle.up()
- success, data = turtle.inspectUp()
- end
- turtle.dig()
- turtle.forward()
- turnToFace(1)
- success, data = turtle.inspectDown()
- while (not success) do
- turtle.dig()
- turtle.down()
- success, data = turtle.inspectDown()
- end
- turtle.dig()
- -- place down saplings
- turtle.select(2)
- turtle.up()
- turtle.placeDown()
- turtle.forward()
- turtle.placeDown()
- turnToFace(2)
- turtle.forward()
- turtle.placeDown()
- turnToFace(3)
- turtle.forward()
- turtle.placeDown()
- turnToFace(2)
- turtle.dig()
- turtle.forward()
- turtle.down()
- -- empty inventory
- for i = 3, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
- turnToFace(0)
- end
- local running = true
- while running do
- giantSpruce()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement