Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 0
- function MoveFront()
- if turtle.detect() then
- turtle.dig()
- if turtle.forward() == false then
- MoveFront()
- end
- else
- turtle.forward()
- end
- end
- function PlaceTorch()
- turtle.select(3)
- turtle.placeDown()
- turtle.select(1)
- end
- function CheckDist()
- if distance % 8 == 0 then
- return true
- else
- return false
- end
- end
- function DigUp()
- if turtle.detectUp() then
- turtle.digUp()
- end
- end
- function DigDown()
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- -- Mines 3x3 infront of the turtle.
- function Mine()
- MoveFront()
- DigUp()
- DigDown()
- turtle.turnLeft()
- MoveFront()
- DigUp()
- DigDown()
- turtle.turnRight()
- turtle.turnRight()
- MoveFront()
- MoveFront()
- DigUp()
- DigDown()
- turtle.back()
- turtle.turnLeft()
- end
- -- Checks if chests are present in slot 2, and if torches are present in slot 3.
- function CheckForItem(n)
- --chest checking
- if n == 1 then
- if turtle.getItemDetail(2).name == "minecraft:chest" then
- return true
- else
- return false
- end
- end
- --torch checking
- if n == 2 then
- if turtle.getItemDetail(2).name == "minecraft:torch" then
- return true
- else
- return false
- end
- end
- end
- -- true if deposits, false if it cant due to no chests
- function Deposit()
- if CheckForItem(1) then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(2)
- turtle.placeDown()
- turtle.select(1)
- for i = 4,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- return true
- else
- return false
- end
- end
- -- attempts to refuel the fucker
- function Refuel()
- for i = 1,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- if turtle.refuel(1) then
- break
- end
- end
- end
- turtle.select(1)
- end
- -- deposit -> refuel -> mine
- while true do
- if turtle.getItemCount(16) > 0 then
- if CheckForItem(1) then
- Deposit()
- else
- break
- end
- elseif turtle.getFuelLevel() < 3 then
- Refuel()
- else
- Mine()
- distance = distance + 1 -- place torch every 8th block
- if CheckDist() then
- if CheckForItem(2) then
- PlaceTorch()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement