Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 0
- local onlight = 0
- local torch = turtle.getItemCount(1)
- local chest = turtle.getItemCount(2)
- local ItemFuel = turtle.getItemCount(3)
- local MD = 3
- local MineTimes = 0
- local Fuel = 0
- local NeedFuel = 0
- local Error = 0
- local Way = 0
- local function Check()
- if torch == 0 then
- print("There are no torch's in Turtle")
- Error = 1
- else
- print("There are torch's in turtle")
- end
- if chest == 0 then
- print("There are no chests")
- Error = 1
- else
- print("There are chest in turtle")
- end
- if ItemFuel == 0 then
- print("No Fuel Items")
- error = 1
- else
- print("There is fuel")
- end
- repeat
- if turtle.getFuelLevel() == "unlimited" then
- print("NO NEED FOR FUEL")
- Needfuel = 0
- elseif turtle.getFuelLevel() < 100 then
- turtle.select(3)
- turtle.refuel(1)
- turtle.select(1)
- Needfuel = 1
- ItemFuel = ItemFuel - 1
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 0
- end
- local function Recheck()
- torch = turtle.getItemCount(1)
- chest = turtle.getItemCount(2)
- ItemFuel = turtle.getItemCount(3)
- Error = 0
- end
- local function WarmUpForBackProgram()
- turtle.turnLeft()
- turtle.turnLeft()
- repeat
- if turtle.detectUp() then
- turtle.digUp()
- end
- until turtle.up()
- end
- local function Back()
- repeat
- if turtle.forward() then
- TB = TB - 1
- end
- if turtle.detect() then
- if TB ~= 0 then
- turtle.dig()
- end
- end
- if turtle.detectDown() then
- turtle.digDown()
- if turtle.getItemCount(1) > torch then
- turtle.select(1)
- turtle.placeDown()
- end
- end
- until TB == 0
- end
- local function FillInChest()
- if chest > 0 then
- back = TB - TF
- WarmUpForBackProgram()
- repeat
- if turtle.forward() then
- back = back - 1
- end
- if turtle.detect() then
- if back ~= 0 then
- turtle.dig()
- end
- end
- until back == 0
- turtle.select(2)
- if turtle.detectDown() then
- turtle.digUp()
- end
- turtle.down()
- turtle.digDown()
- turtle.placeDown()
- chest = chest - 1
- for slot = 5, 16 do
- turtle.select(slot)
- turtle.dropDown()
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- for slot = 0, TB - TF do
- turtle.forward()
- end
- turtle.down()
- else
- print("Turtle run out of chest")
- os.shutdown()
- end
- end
- local function ForwardM()
- repeat
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then
- TF = TF - 1
- onlight = onlight + 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.select(4)
- turtle.placeDown()
- turtle.select(1)
- if onlight == 8 then
- if torch > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torch = torch - 1
- onlight = onlight - 8
- else
- print("Turtle run out of torchs")
- os.shutdown()
- end
- end
- if turtle.getItemCount(16) > 0 then
- FillInChest()
- end
- repeat
- if turtle.getFuelLevel() == "unlimited" then
- print("NO NEED FOR FUEL")
- Needfuel = 0
- elseif turtle.getFuelLevel() < 100 then
- turtle.select(3)
- turtle.refuel(1)
- turtle.select(1)
- Needfuel = 1
- ItemFuel = ItemFuel - 1
- elseif ItemFuel == 0 then
- print("Turtle run out of fuel")
- os.shutdown()
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 0
- until TF == 0
- end
- local function MultiMines()
- if turtle.detectDown() then
- turtle.digDown()
- end
- if Way == 1 then
- turtle.turnLeft()
- turtle.down()
- else
- turtle.turnRight()
- turtle.down()
- end
- repeat
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then
- MD = MD - 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.select(4)
- turtle.placeDown()
- turtle.select(1)
- until MD == 0
- if Way == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if MineTimes == 0 then
- print("Turtle is done")
- else
- MineTimes = MineTimes - 1
- end
- end
- local function Restart()
- TF = distance
- TB = distance
- MD = 3
- end
- function Start()
- repeat
- onlight = 2
- ForwardM()
- WarmUpForBackProgram()
- Back()
- MultiMines()
- Restart()
- until MineTimes == 0
- end
- print("Hi There Welcome to Mining Turtle Program")
- print("How Far Will Turtle Go")
- input = io.read()
- distance = tonumber(input)
- TF = distance
- TB = distance
- print("Left or Right")
- print("0 = Left and 1 = Right")
- input2 = io.read()
- Way = tonumber(input2)
- print("How Many Times")
- input3 = io.read()
- MineTimes = tonumber(input3)
- Recheck()
- Check()
- if Error == 1 then
- repeat
- sleep(10)
- Recheck()
- Check()
- until Error == 0
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement