Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 0 -- the distance you want turtle to go
- local onlight = 0
- local torch = turtle.getItemCount(1) -- Checks the amount of torches in slot 1
- local chest = turtle.getItemCount(2) -- Checks the amount of chests in slot 2
- local ItemFuel = turtle.getItemCount(3) -- Checks the amount of Coal in slot 3
- local Fuel = 0
- local NeedFuel = 0
- local Error = 0
- --Checking
- 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 :D")
- end
- if chest == 0 then
- print("there are no chests :(")
- Error = 1
- else
- print("There are chest in turtle :D")
- end
- if ItemFuel == 0 then
- print("No Fuel Items :(")
- error = 1
- else
- print("there is fuel :D")
- 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)
- 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
- --Mining
- local function ForwardM()
- repeat
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
- TF = TF - 1
- onlight = onlight + 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.select(4)
- turtle.placeDown()
- if onlight == 10 then -- Every 10 Block turtle place torch
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torch = torch - 1
- onlight = onlight - 10
- end
- if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
- turtle.select(2)
- for i = 0, 10 do
- turtle.dig()
- sleep(0.5)
- end
- turtle.place()
- chest = chest - 1
- for slot = 5, 16 do
- turtle.select(slot)
- turtle.drop()
- sleep(1.5)
- end
- turtle.select(2)
- turtle.dig()
- turtle.select(5)
- 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)
- Needfuel = 1
- ItemFuel = ItemFuel - 1
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 0
- until TF == 0
- end
- --Warm Up For Back Program
- local function WarmUpForBackProgram() -- To make turn around so it can go back
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- end
- --Back Program
- local function Back()
- repeat
- if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
- TB = TB - 1
- end
- if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
- turtle.dig()
- end
- until TB == 0
- end
- -- Restart
- local function Restart()
- TF = distance
- TB = distance
- onlight = 0
- end
- local function FillEnder()
- turtle.down()
- sleep(1.5)
- turtle.dig()
- sleep(1.5)
- turtle.select(2)
- turtle.place()
- for slot = 4, 16 do
- turtle.select(slot)
- turtle.drop()
- sleep(1.5)
- end
- end
- -- Starting
- function Start()
- ForwardM()
- WarmUpForBackProgram()
- Back()
- Restart()
- FillEnder()
- term.clear()
- print("~~~~~~~~~~~~~~~~~~")
- print("I'm Done Master :D")
- print("~~~~~~~~~~~~~~~~~~")
- end
- -- Start
- term.clear()
- print("Hi There Welcome to the Strip Mining Program")
- print("How Far Will Turtle Go")
- input = io.read()
- distance = tonumber(input)
- TF = distance
- TB = distance
- print("Slot 1 = Torches, Slot 2 = EnderChest, Slot 3 = Coal")
- print("When Ready, Say OK")
- input2 = io.read()
- if input2 == "OK" then
- Check()
- else
- print("I don't understand you...")
- end
- if Error == 1 then
- repeat
- sleep(10)
- Recheck()
- Check()
- until Error == 0
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement