Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function modrefuel()
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- print("Slot "..i.." is valid fuel.")
- turtle.refuel()
- end
- end
- turtle.select(1)
- end
- function digLine(length)
- local backCheck = false
- local forwardCheck = false
- for i = 2, length do
- while (forwardCheck == false) do
- turtle.dig()
- forwardCheck = turtle.forward()
- end
- forwardCheck = false
- end
- for i = 2, length do
- while (backCheck == false) do
- backCheck = turtle.back()
- end
- backCheck = false
- end
- end
- function digSquare(height, width)
- local upCheck = false
- local downCheck = false
- if width > 1 then
- digLine(width)
- end
- for i = 1, height do
- while (upCheck == false) do
- turtle.digUp()
- upCheck = turtle.up()
- end
- upCheck = false
- if width > 1 then
- digLine(width)
- end
- end
- for i = 1, height do
- while (downCheck == false) do
- turtle.digDown()
- downCheck = turtle.down()
- end
- downCheck = false
- end
- function mine(depth, height, width, chestX, chestY, chestZ)
- local backCheck = false
- local downCheck = false
- local forwardCheck = false
- local upCheck = false
- for i = 1, depth do
- print("Digging forward!")
- turtle.dig()
- while (forwardCheck == false) do
- turtle.dig()
- forwardCheck = turtle.forward()
- end
- forwardCheck = false
- turtle.turnRight()
- for i = 1, width do
- turtle.dig()
- while (forwardCheck == false) do
- turtle.dig()
- forwardCheck = turtle.forward()
- end
- forwardCheck = false
- end
- for i = 1, width do
- while (backCheck == false) do
- backCheck = turtle.back()
- end
- backCheck = false
- end
- turtle.turnLeft()
- for i = 1, height do
- print("Digging up!")
- turtle.digUp()
- while (upCheck == false) do
- turtle.digUp()
- upCheck = turtle.up()
- end
- upCheck = false
- print("Turning right!")
- turtle.turnRight()
- for i = 1, width do
- print("Digging wide, right!")
- turtle.dig()
- while (forwardCheck == false) do
- turtle.dig()
- forwardCheck = turtle.forward()
- end
- forwardCheck = false
- end
- for i = 1, width do
- print("Heading back!")
- while (backCheck == false) do
- backCheck = turtle.back()
- end
- backCheck = false
- end
- print("Turning left!")
- turtle.turnLeft()
- end
- for i = 1, height do
- print("Heading down!")
- while (downCheck == false) do
- turtle.digDown()
- downCheck = turtle.down()
- end
- downCheck = false
- end
- print("Checking for fuel...")
- modrefuel()
- print("Checking inventory full...")
- fullCheck(chestX, chestY, chestZ)
- end
- end
- function dropOff(chestX, chestY, chestZ)
- local chestCheck = false
- print("Inventory full, dropping off!")
- local turtleX, turtleY, turtleZ = gps.locate()
- if (turtleX == nil) or (turtleY == nil) or (turtleZ == nil) then
- print("GPS not functioning or out of range")
- end
- print("I am at (" ..turtleX.. ", " ..turtleY.. ", " ..turtleZ.. ")")
- shell.run("goto", chestX, chestZ, chestY)
- for i = 1, 16 do
- turtle.select(i)
- while (chestCheck == false) do
- chestCheck = turtle.dropDown()
- if (chestCheck == false) then
- print("Chest is full!")
- sleep(10)
- end
- end
- chestCheck = false
- end
- turtle.select(1)
- shell.run("goto", turtleX, turtleZ, turtleY)
- end
- function fullCheck(chestX, chestY, chestZ)
- if turtle.getItemCount(16) > 0 then
- dropOff(chestX, chestY, chestZ)
- end
- end
- local chestCheck
- local chestX
- local chestY
- local chestZ
- local turtleX
- local turtleY
- local turtleZ
- local digDepth
- local digHeight
- local digWidth
- --print("Input chest coordinates\n")
- --print("X: ")
- --chestX = io.read()
- --print("\nZ: ")
- --chestZ = io.read()
- --print("\nY: ")
- --chestY = io.read()
- --print(chestX, chestY, chestZ)
- --print("Input digging dimensions\n")
- --print("Depth: ")
- --digDepth = io.read()
- --print("\nHeight: ")
- --digHeight = io.read()
- --print("\nWidth: ")
- --digWidth = io.read()
- --print(digDepth, digHeight, digWidth)
- --print("Running mining protocol")
- digSquare(4, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement