Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Version = 1.00
- --Local
- local miningDistance = 0 -- How Far Did User Pick
- local shouldPlaceTorch = 0 -- When to Place Torch
- local TorchCount = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
- local ItemChests = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
- local FuelItemCount = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
- local MD = 3 -- How Many Blocks Apart From Each Mine
- local NumberOfMines = 0 -- If Multi Mines Are ON then This will keep Count
- 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 Way = 0 -- 1 = Left and 2 = Right
- local exception = false -- Used in initial and repeated inventory checks
- local function FuelTurtle()
- repeat
- if turtle.getFuelLevel() == "unlimited" then
- print("INFO: Server set for unlimited fuel")
- Needfuel = 0
- elseif turtle.getFuelLevel() < 100 then
- print("INFO: Refueling from slot 3")
- turtle.select(3)
- turtle.refuel(1)
- Needfuel = 1
- FuelItemCount = FuelItemCount - 1
- elseif FuelItemCount == 0 then
- print("ERROR: Turtle ran out of fuel.")
- os.shutdown()
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 0
- end
- local function CheckTurtleInventory()
- if TorchCount == 0 then
- print("ERROR: Turtle REQUIRES torches in slot 1!")
- return true
- else
- print("INFO: Turtle has " .. TorchCount .. " starting torch(es).")
- end
- if ItemChests == 0 then
- print("ERROR: Turtle REQUIRES chests in slot 2!")
- return true
- else
- print("INFO: Turtle has " .. ItemChests .. " chests.")
- end
- if FuelItemCount == 0 then
- print("ERROR: Turtle REQUIRES fuel items in slot 3! (Wooden Items, Types of Coal, Lava, Blaze Rod, etc.")
- return true
- else
- print("INFO: Turtle has " .. FuelItemCount .. " fuel item(s).")
- end
- FuelTurtle()
- return false
- 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
- shouldPlaceTorch = shouldPlaceTorch + 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.select(4)
- turtle.placeDown()
- if shouldPlaceTorch == 8 then -- Every 10 Block turtle place torch
- if TorchCount > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- TorchCount = TorchCount - 1
- shouldPlaceTorch = shouldPlaceTorch - 8
- else
- print("ERROR: Turtle ran out of torches!")
- return true
- end
- end
- if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
- if ItemChests > 0 then
- turtle.select(2)
- turtle.digDown()
- turtle.placeDown()
- ItemChests = ItemChests - 1
- for slot = 5, 16 do
- turtle.select(slot)
- turtle.dropDown()
- sleep(1.5)
- end
- turtle.select(5)
- else
- print("ERROR: Turtle ran out of chests!")
- return true
- end
- end
- FuelTurtle()
- until TF == 0
- return false
- 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
- if TB ~= 0 then
- turtle.dig()
- end
- end
- until TB == 0
- end
- -- Multimines Program
- local function MultiMines()
- if Way == 2 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
- until MD == 0
- if Way == 2 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if NumberOfMines == 0 then
- print("INFO: Mining Complete!")
- else
- NumberOfMines = NumberOfMines - 1
- end
- end
- -- Restart
- local function Restart()
- TF = miningDistance
- TB = miningDistance
- MD = 3
- shouldPlaceTorch = 0
- end
- -- Starting
- function Start()
- repeat
- exception = ForwardM()
- if exception == true then
- return
- end
- WarmUpForBackProgram()
- Back()
- MultiMines()
- Restart()
- until NumberOfMines == 0
- end
- -- Start
- print("== Mining Turtle v" .. Version .. "==")
- print("This program allows your ComputerCraft turtle to Stripmine for you.")
- print("How many blocks forward do you want each strip to be?")
- input = io.read()
- miningDistance = tonumber(input)
- TF = miningDistance
- TB = miningDistance
- print("How many strips do you want the turtle to mine?")
- input3 = io.read()
- NumberOfMines = tonumber(input3)
- if NumberOfMines > 1 then
- while Way == 0
- do
- print("Would you like each strip mine to be made to the left or right of the original?")
- input2 = io.read()
- if input2 == "left" then
- Way = 1
- elseif input2 == "right" then
- Way = 2
- else
- print("ERROR: The only proper responses are 'left' or 'right'. (without the quotes)")
- end
- end
- end
- exception = CheckTurtleInventory()
- if exception == false then
- Start()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement