Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Local
- local distance = 0 -- How Far Did User Pick
- local torchDist = 12 -- When to Place Torch
- local onlight = 0
- local width = distance
- local Fuel = 0 -- if 2 then it is unlimited no fuel needed
- local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
- local Error = 0 -- 0 = No Error and 1 = Error
- local Way = 0 -- 0 = Left and 1 = Right
- --Place torch
- local function PlaceTorch()
- if useTorch == "y" then
- if onlight <= 0 then
- repeat
- if turtle.getItemCount(3) > 0 then
- turtle.select(3)
- turtle.placeDown()
- turtle.select(4)
- onlight = torchDist
- else
- print("turtle run out of torchs")
- sleep(10)
- end
- until onlight > 0
- else
- onlight = onlight - 1
- end
- end
- end
- --Empty slot 4 to 16 will go to chest
- local function EmptyInventory()
- repeat
- if turtle.getItemCount(1) > 0 then
- turtle.select(1)
- turtle.digDown()
- turtle.placeDown()
- for slot = 4, 16 do
- turtle.select(slot)
- turtle.dropDown()
- sleep(0.5)
- end
- turtle.select(4)
- else
- print("turtle run out of chest")
- sleep(10)
- end
- until turtle.getItemCount(16) == 0
- end
- --Refueling
- local function RefuelTurtle()
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 10 then
- repeat
- Needfuel = 1
- ItemFuel = turtle.getItemCount(2)
- if ItemFuel > 0 then
- turtle.select(2)
- turtle.refuel(1)
- turtle.select(4)
- else
- print("turtle run out of fuel")
- sleep(10)
- end
- until NeedFuel == 0
- end
- end
- --Turn around
- local function turnAround()
- if Way == 0 then
- Way = 1
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- width = width - 1
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- elseif Way == 1 then
- Way = 0
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- width = width - 1
- turtle.digUp()
- turtle.digDown()
- turtle.turnRight()
- end
- end
- --Move forward
- local function Forward()
- repeat
- if turtle.getItemCount(16) > 0 then
- EmptyInventory()
- end
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
- moves = moves - 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- PlaceTorch()
- RefuelTurtle()
- until moves == 0
- end
- --Get to start position
- function toStart()
- turtle.turnRight()
- PlaceTorch()
- moves = distance / 2
- Forward()
- turtle.turnLeft()
- onlight = 0
- end
- --Full mining cycle
- function Mining()
- turtle.select(4)
- turtle.digDown()
- PlaceTorch()
- width = distance
- repeat
- moves = distance
- Forward()
- turnAround()
- until width == 0
- Forward()
- end
- --Start
- print("Hi There Welcome to Mining Turtle Program")
- print("Chest in slot 1")
- print("Fuel in slot 2")
- print("Torch in slot 3")
- print("Use torches y/n")
- useTorch = read()
- print("How Far Will Turtle Go")
- distance = tonumber(read()) - 1
- toStart()
- Mining()
- EmptyInventory()
- print("Done")
Add Comment
Please, Sign In to add comment