Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle Position
- posX, posY, posZ = 0, 0, 0
- depth = 1
- startDepth = 0
- -- Y-Level to stop At
- stopY = 0
- -- Chest info
- cardinalChest = ""
- -- Direction to mine
- turtleTurn = ""
- -- Distance to mine
- length = 0
- -- Amount of strips to mine
- width = 0
- -- Torch & Line Count
- count = 0
- lineCount = 0
- term.clear()
- print("Existing parameters include:")
- print("1) You must have the turtle and chest on one of the same axes.")
- print("2) The turtle must be moving in the same direction that the chest opens.")
- print("3) Place at least 1 coal in the 1st slot.")
- print("4) You must enter an even number for width.")
- print("---------------------------------------")
- local x = term.write("Press [Enter] to Continue")
- x = read()
- term.clear()
- -- term.write("What is the turtle's X? ")
- -- posX = read()
- -- term.write("What is the turtle's Z? ")
- -- posZ = read()
- -- term.write("What is the chest's X? ")
- -- chestX = read()
- -- term.write("What is the chest's Z? ")
- -- chestZ = read()
- term.write("Starting Y-Level: ")
- posY = tonumber(read())
- term.write("Stopping Y-Level: ")
- stopY = tonumber(read())
- term.write("Blocks beneath the chest? ")
- startDepth = read()
- if startDepth == nil or startDepth == '' then
- startDepth = 0
- end
- depth = depth + startDepth
- term.write("Which way do you want to mine? ")
- print("Enter 'r' or 'l'")
- turtleTurn = read()
- if turtleTurn == "r" then
- cardinalChest = "l"
- else
- cardinalChest = "r"
- end
- term.write("Width: ")
- width = tonumber(read())
- term.write("Length: ")
- length = tonumber(read()) - 1
- function turnBack()
- if turtleTurn == "r" then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- end
- end
- function turnForward()
- if turtleTurn == "r" then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.turnRight()
- end
- end
- function isAllthemodiumUp()
- for i = 1, 5, 1 do
- turtle.digUp()
- turtle.up()
- end
- for i = 1, 5, 1 do
- turtle.dig()
- turtle.forward()
- end
- for i = 1, 5, 1 do
- turtle.digDown()
- turtle.down()
- end
- end
- function isAllthemodiumDown()
- for i = 1, 5, 1 do
- turtle.digDown()
- turtle.down()
- end
- for i = 1, 5, 1 do
- turtle.dig()
- turtle.forward()
- end
- for i = 1, 5, 1 do
- turtle.digUp()
- turtle.up()
- end
- end
- function tunnel(extraDistance)
- i = 0
- print("extraDistance: ", extraDistance)
- totalDistance = length + extraDistance
- while i < totalDistance do
- local isBlock, data = turtle.inspect()
- if string.find(textutils.serialise(data.name), "allthemodium_ore") then
- local isBlock, data = turtle.inspectUp()
- if string.find(textutils.serialise(data.name), "allthemodium_ore") then
- isAllthemodiumDown()
- else
- isAllthemodiumUp()
- end
- i = i + 5
- else
- turtle.dig()
- turtle.forward()
- i = i + 1
- end
- turtle.digUp()
- turtle.digDown()
- end
- if i > length then
- print("length - i", i - length)
- return (i - length)
- else
- return 0
- end
- end
- function drop()
- coal = turtle.getItemCount(1)
- if coal > 1 then
- halfCoal = math.floor(coal / 2)
- turtle.drop(halfCoal)
- end
- for i=2, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function moveForward()
- while turtle.detect() == false do
- turtle.forward()
- turtleSteps = turtleSteps + 1
- end
- local isBlock, data = turtle.inspect()
- if string.find(textutils.serialise(data.name), "chest") then
- drop()
- else
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtleSteps = turtleSteps + 1
- moveForward()
- end
- end
- function chest(width, depth)
- turtleSteps = 0
- if cardinalChest == "r" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- for i=1, depth, 1 do
- turtle.up()
- end
- moveForward()
- if turtleSteps >= width - 1 then
- if cardinalChest == "r" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for i=1, depth + 2, 1 do
- turtle.digDown()
- turtle.down()
- end
- else
- for i=1, depth, 1 do
- turtle.down()
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=1, turtleSteps, 1 do
- turtle.forward()
- end
- if cardinalChest == "r" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- function refuel()
- turtle.select(1)
- fuel = turtle.getItemCount(1)
- if fuel > 1 then
- turtle.refuel(fuel - 1)
- end
- local fuel = 0
- local fuel = turtle.getFuelLevel()
- print("Fuel remaining:")
- print(fuel)
- end
- timeStart = os.time("utc") * 3600
- while true do
- linesCompleted = 0
- extraDistance = 0
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- for i=1, (width / 2), 1 do
- extraDistance = tunnel(extraDistance)
- turnBack()
- extraDistance = tunnel(extraDistance)
- if linesCompleted ~= width - 2 then
- turnForward()
- else
- turtle.turnLeft()
- turtle.turnLeft()
- end
- linesCompleted = linesCompleted + 2
- end
- chest(width, depth)
- refuel()
- print("Currently on level: "..posY - 1)
- depth = depth + 3
- if posY <= stopY then
- if cardinalChest == "r" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- for i=1, depth, 1 do
- turtle.up()
- end
- break
- end
- posY = posY - 3
- end
- timeEnd = os.time("utc") * 3600
- totalTime = math.ceil((timeEnd - timeStart) / 60)
- print("The turtle took: " .. totalTime .. " minutes to complete")
- print("Turtle has reached level -57 and completed the quarry")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement