Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Description: Quarries a 16 x 16 area, and returns to a drop off inventory directly above it's starting location.
- -- Usage info:
- -- 1: type in pastebin get <code at end of url> <desired program name>
- -- 2: Place mining turtle in bottom right corner of chunk you want to quarry, put it with in the quarry boundaries.
- -- 3: Place chest or other drop off inventory above the turtle.
- -- 4: Place fuel in slot one of turtle.
- -- 5: Run program, and come back to see the hole later.
- -- Variable declaration zone
- local level = 0 -- Level turtle just completed
- local currentLevel = 0 -- Level turtle is currently on
- local layer = 0 -- Layers dug
- local direction = "right" -- Direction turtle must turn in next
- local x = 1 -- x location
- local z = 1 -- z location
- local noBedrock = true
- local slot = 1
- local goHome = 0
- -- End variable declaration zone
- -- Function delaration zone
- -- Refuel script
- function refuel()
- print("Checking fuel...")
- if turtle.getFuelLevel() < 500 then
- print("Refueling. Only ", turtle.getFuelLevel(), " left.")
- turtle.select(1)
- turtle.refuel(15)
- print("Fuel inceased to: ", turtle.getFuelLevel())
- end
- end
- -- Digs a layer
- function digLayer()
- print("Preparing to dig...")
- for x = 1,16 do
- -- Digs a 16 block long line
- for z = 1,15 do
- turtle.dig()
- while turtle.attack() do
- sleep(1)
- end
- turtle.forward()
- end
- -- Determines if it needs to turn left or right to dig the next row
- if direction == "left" and x ~= 16 then
- turtle.turnLeft()
- turtle.dig()
- while turtle.attack() do
- sleep(1)
- end
- turtle.forward()
- turtle.turnLeft()
- direction = "right"
- elseif direction == "right" and x ~= 16 then
- turtle.turnRight()
- turtle.dig()
- while turtle.attack() do
- sleep(1)
- end
- turtle.forward()
- turtle.turnRight()
- direction = "left"
- end
- end
- print("Layer complete.")
- end
- -- Checks for bedrock
- function checkBedrock()
- print("Checking for bedrock...")
- if turtle.digDown() == true then
- turtle.select(2)
- turtle.placeDown()
- print("Not yet at bedrock.")
- elseif turtle.down() == true then
- turtle.up()
- print("Not yet at bedrock.")
- else
- noBedrock = false
- print("At bedrock.")
- end
- end
- -- Returns to home location to drop off resources
- function dropOff()
- print("Preparing dropoff sequence...")
- -- Return home location
- print("Returning home...")
- turtle.turnRight()
- for goHome = 1,15 do
- while turtle.attack() do
- sleep(1)
- end
- turtle.forward()
- end
- -- Rises to the surface to drop items off
- level = 0
- while turtle.attackUp() do
- sleep(1)
- end
- while turtle.up() do
- level = level + 1
- while turtle.attackUp() do
- sleep(1)
- end
- end
- -- Empties inventory into drop off
- print("Preparing to empty inventory...")
- for slot = 2,16 do
- turtle.select(slot)
- turtle.dropUp()
- end
- print("Inventory cleared. All items dropped off.")
- -- Goes back down to desired layer
- retriveFuel()
- print("Returning to correct floor...")
- currentLevel = 0
- while turtle.attackDown() do
- sleep(1)
- end
- while level ~= currentLevel do
- turtle.down()
- while turtle.attackDown() do
- sleep(1)
- end
- currentLevel = currentLevel + 1
- end
- print("Back at correct floor.")
- end
- -- Ending sequence
- function endSequence()
- print("Starting end sequence...")
- while turtle.attackUp() do
- sleep(1)
- end
- while turtle.up() do
- while turtle.attackUp() do
- sleep(1)
- end
- end
- print("Total number of layers dug: ", layer)
- print("Mission complete. Master shall not punish me.")
- end
- -- Layer preparation
- function layerPrep()
- print("Preforming next layer preparation...")
- turtle.turnRight()
- direction = "right"
- turtle.digDown()
- turtle.down()
- print("Next layer prepared")
- end
- function retriveFuel()
- turtle.turnLeft()
- turtle.select(1)
- local fuelCount = turtle.getItemCount(1)
- local toRefuel = 64 - fuelCount
- print("Retrieving fuel... ", toRefuel, " needed.")
- turtle.suck(toRefuel)
- turtle.turnRight()
- end
- -- End function declaration zone
- -- Main running sequence
- while noBedrock do
- refuel()
- checkBedrock()
- if noBedrock == true then
- digLayer()
- dropOff()
- layerPrep()
- end
- layer = layer + 1
- end
- endSequence()
- -- End main running sequence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement