Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local shouldFuel = false
- local receivePort = 62101
- local sendPort = 62100
- local modem = peripheral.wrap("left")
- local forbidItems = {
- "lavastone",
- "cobblestone",
- "diorite",
- "dirt",
- "gravel",
- "granite",
- "andesite",
- "scoria",
- "marble"
- }
- function termReset()
- term.clear()
- term.setCursorPos(1,1)
- end
- function refu()
- if not shouldFuel then
- return
- end
- turtle.select(1)
- if (turtle.getItemCount() < 1) then
- term.clear()
- print("No fuel!")
- return
- end
- if not (turtle.refuel()) then
- term.clear()
- print("Refuel Error!")
- return
- end
- end
- function digRound(right)
- while (turtle.detect()) do
- turtle.dig()
- end
- if (right) then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- end
- function digRoundSolo()
- while (turtle.detect()) do
- turtle.dig()
- end
- end
- function report(done)
- local x, y, z = gps.locate()
- if not x then
- print("Can't GPS")
- return
- end
- local transmitData = {}
- transmitData["x"] = x
- transmitData["y"] = y
- transmitData["z"] = z
- transmitData["label"] = os.getComputerLabel()
- transmitData["id"] = os.getComputerID()
- transmitData["done"] = done
- modem.transmit(sendPort, receivePort, transmitData)
- end
- local limitForward
- while not (tonumber(limitForward)) do
- termReset()
- print("How far would you like the turtle to dig in forward blocks? Must be number.");
- limitForward = read()
- end
- limitForward = math.floor(tonumber(limitForward))
- local limitUp
- while not (tonumber(limitUp)) do
- termReset()
- print("How far would you like the turtle to dig in vertical blocks? Must be number.");
- limitUp = read()
- end
- limitUp = math.floor(tonumber(limitUp))
- local limtSide
- while not (tonumber(limtSide)) do
- termReset()
- print("How far would you like the turtle to dig in horizontal blocks? Must be number.");
- limtSide = read()
- end
- limtSide = math.floor(tonumber(limtSide))
- local temp = 5
- termReset()
- print("Make sure turtle is in the bottom left of grid")
- while (temp > 0) do
- sleep(1)
- temp = temp - 1
- end
- termReset()
- print("running " .. limtSide .."x".. limitUp .." mine for " .. limitForward .. " blocks")
- local path = 0
- refu()
- while (path < limitForward) do
- if (turtle.getFuelLevel() < 1) then
- refu()
- end
- local doneUp = 1
- while (doneUp < limitUp) do
- turtle.up()
- doneUp = doneUp + 1
- end
- local doneSide = 0
- doneUp = 1
- while (doneUp <= limitUp) do
- doneSide = 0
- while (doneSide < limtSide) do
- if (doneUp % 2 ~= 0) then
- if (doneSide >= limtSide - 1) then
- digRoundSolo()
- else
- digRound(true)
- end
- doneSide = doneSide + 1
- else
- if (doneSide >= limtSide - 1) then
- digRoundSolo()
- else
- digRound(false)
- end
- doneSide = doneSide + 1
- end
- end
- turtle.down()
- doneUp = doneUp + 1
- end
- turtle.forward()
- if (limitUp % 2 ~= 0) then
- doneSide = 0
- turtle.turnLeft()
- while (doneSide < limtSide) do
- turtle.forward()
- doneSide = doneSide + 1
- end
- turtle.turnRight()
- end
- local slot = 1
- while (slot <= 16) do
- turtle.select(slot)
- local data = turtle.getItemDetail()
- for i, v in pairs(forbidItems) do
- if (data) then
- if string.find(data.name, v) then
- turtle.dropDown(turtle.getItemCount())
- end
- end
- end
- slot = slot + 1
- end
- path = path + 1
- report(false)
- end
- termReset()
- print("Done! Returning Home")
- turtle.turnRight()
- turtle.turnRight()
- while (path > 0) do
- turtle.forward()
- path = path - 1
- end
- termReset()
- print("Done!")
- report(true)
Advertisement
Add Comment
Please, Sign In to add comment