Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Local
- local distance = 0 -- How Far Did User Pick
- local onlight = 0 -- When to Place Torch
- local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
- local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
- local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
- local MD = 3 -- How Many Blocks Apart From Each Mine
- local MineTimes = 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 Error = 0 -- 0 = No Error and 1 = Error
- local Way = 0 -- 0 = Left and 1 = Right
- --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")
- 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)
- Needfuel = 1
- ItemFuel = ItemFuel - 1
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 00
- end
- local function aboutFace()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function checkLava()
- local success, data = turtle.inspect()
- if success then
- if data.name == "minecraft:flowing_lava" then
- turtle.place()
- end
- end
- end
- local function checkLavaAbove()
- local success, data = turtle.inspectUp()
- if success then
- if data.name == "minecraft:flowing_lava" then
- turtle.placeUp()
- end
- end
- end
- -- Recheck if user forget something turtle will check after 15 sec
- 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() --turtle tunnels a 1x2 space; this will place a block down if none exists below, regardless
- --newnew 3/1 -2
- turtle.turnRight()
- checkLava() --check for lava and place down
- aboutFace() -- 180
- checkLava()
- turtle.turnRight() --return turtle to original direction
- --new 3/1 - 1
- turtle.up()
- turtle.turnRight()
- checkLava()
- checkLavaAbove()
- aboutFace()
- checkLava()
- turtle.turnRight()
- turtle.down()
- -- end new
- if onlight == 8 then -- Every 10 Block turtle place torch
- if torch > 0 then
- aboutFace()
- turtle.select(1)
- turtle.place()
- aboutFace() --180 degree turn
- torch = torch - 1
- onlight = onlight - 8
- else
- print("turtle run out of torchs")
- os.shutdown()
- end
- end
- if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
- if chest > 0 then
- turtle.select(2)
- turtle.digDown()
- turtle.placeDown()
- chest = chest - 1
- for slot = 5, 16 do
- turtle.select(slot)
- turtle.dropDown()
- sleep(1.5)
- end
- turtle.select(5)
- else
- print("turtle run out of chest")
- os.shutdown()
- end
- 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 ItemFuel == 0 then
- print("turtle run out of fuel")
- os.shutdown()
- elseif NeedFuel == 1 then
- Needfuel = 0
- end
- until NeedFuel == 0
- until forwardProgress == stripLength
- end
- local function deposit()
- for slot = 5, 16 do --drops off
- turtle.select(slot)
- turtle.dropDown()
- sleep(1.5)
- end
- turtle.select(5) --prepares to load items again
- end
- local function NextStrip()
- --get the turtle in place for next strip min
- --we start from chest orginal position
- local distanceToStrip = stripProgress * MD
- repeat
- if turtle.forward() then
- distanceToStrip = distanceToStrip - 1
- end
- if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
- if distanceToStrip ~= 0 then
- turtle.dig()
- end
- end
- until distanceToStrip == 0
- turtle.turnLeft()
- end
- local function ReturnToStrip()
- aboutFace()
- turtle.up()
- repeat
- if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
- returnProgress = returnProgress + 1
- end
- if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
- if returnProgress ~= stripLength then
- turtle.dig()
- end
- end
- until returnProgress == stripLength
- end
- local function ReturnToChest()
- local distanceToChest = stripProgress * MD
- if distanceToChest == 0 then -- just
- deposit()
- end
- turtle.turnRight()
- repeat
- if turtle.forward() then
- distanceToChest = distanceToChest - 1
- end
- until distanceToChest == 0
- deposit()
- aboutFace()
- end
- -- Restart
- local function Restart()
- forwardProgress = distance
- returnProgress = distance
- MD = 3
- onlight = 0
- end
- -- Starting
- function Start()
- repeat
- ForwardM()
- ReturnToStrip()
- turtle.down()
- ReturnToChest()
- NextStrip()
- Restart()
- until == 0
- end
- -- Start
- print("Awesome mining program TWO")
- print("Ready to go?")
- os.pullEvent("key")
- stripLength = 100
- forwardProgress = 0
- returnProgress = 0
- Way = 1 --RIGHT
- strips = 10
- stripProgress = 0
- 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