Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - --[[
 - GPS Deploy: http://www.computercraft.info/forums2/index.php?/topic/9528-gps-deploy-11-updated-04012014/page__view__findpost__p__264468
 - pastebin get VXAyXqBv gpsDeploy
 - Special Turtle Script which mines everything(!) it can. IMPORTEND: Setup an special mining-Dimension (with RFTools)!!
 - Requires an already active GPS-System and NoFuel Mode.
 - Digging down till bedrock and ignores bedrock (y = ~4)
 - Maybe you must craft a 'Wireless Mining Turtle' yourself, but dont use an Advanced Turtle.
 - Place the Turtle so that a drop-chest is behind.
 - --]]
 - function getDirection()
 - local f = 0
 - local x, y, z = gps.locate(5,false)
 - y = nil
 - if not turtle.forward() then
 - error("I am against a wall.")
 - end
 - local newx, newy, newz = gps.locate(5,false)
 - newy = nil
 - turtle.back()
 - --f: South=0, West=1, North=2, East=3
 - if newz > z then
 - f = 0
 - elseif newx < x then
 - f = 1
 - elseif newz < z then
 - f = 2
 - elseif newx > x then
 - f = 3
 - end
 - return f
 - end
 - -- ausrichten
 - -- Receive an absolute directon and does the propiate turns
 - function align(newDir)
 - local rest = math.abs(currentPos.f - newDir)
 - while currentPos.f ~= newDir do
 - if (rest > 2 and currentPos.f < newDir) or (rest <= 2 and currentPos.f > newDir) then
 - turtle.turnLeft()
 - currentPos.f = currentPos.f - 1
 - else
 - turtle.turnRight()
 - currentPos.f = currentPos.f + 1
 - end
 - if currentPos.f > 3 then
 - currentPos.f = 0
 - elseif currentPos.f < 0 then
 - currentPos.f = 3
 - end
 - end
 - end
 - function forward() --Forward movement
 - --Move forward
 - local i = 0 --Iterator for bedrock/strong player detection
 - while not turtle.forward() do
 - if not turtle.dig() then --Detect blocks
 - i = i + 1
 - turtle.attack() --Detect entities
 - if i == 30 then
 - return false --If movement fails
 - end
 - end
 - end
 - --Clear above and below
 - while turtle.detectUp() do
 - turtle.digUp()
 - end
 - while turtle.detectDown() do
 - turtle.digDown()
 - end
 - --Position tracking
 - if currentpos.f == 0 then
 - currentpos.z = currentpos.z + 1
 - elseif currentpos.f == 1 then
 - currentpos.x = currentpos.x - 1
 - elseif currentpos.f == 2 then
 - currentpos.z = currentpos.z - 1
 - elseif currentpos.f == 3 then
 - currentpos.x = currentpos.x + 1
 - else
 - running = false
 - error("Something went wrong with the direction :P/>/>/>/>/>/>")
 - end
 - return true
 - end
 - --Right turn with position tracking
 - function turnRight()
 - turtle.turnRight()
 - if currentpos.f < 3 then
 - currentpos.f = currentpos.f + 1
 - else
 - currentpos.f = 0
 - end
 - end
 - --Left turn with position tracking
 - function turnLeft()
 - turtle.turnLeft()
 - if currentpos.f > 0 then
 - currentpos.f = currentpos.f - 1
 - else
 - currentpos.f = 3
 - end
 - end
 - --Downward movement
 - function down()
 - --Move down
 - local i = 0 --Iterator for bedrock detection
 - while not turtle.down() do
 - if not turtle.digDown() then --Detect blocks
 - i = i + 1
 - turtle.attackDown() --Detect entities
 - if i == 25 then
 - return false --If movement fails
 - end
 - end
 - end
 - --Position tracking
 - currentpos.y = currentpos.y - 1
 - if serverID ~= -1 then
 - rednet.send(serverID,textutils.serialize({Type = "PosUpdate",Doen=currentpos.y}))
 - end
 - return true
 - end
 - --Drop mined resources, display amounts
 - function dropAll()
 - local mined = 0
 - turtle.turnRight()
 - turtle.turnRight()
 - for i=1,16 do
 - turtle.select(i)
 - mined = mined + turtle.getItemCount(i)
 - turtle.drop()
 - end
 - --This will send to rednet soon
 - totalMined = totalMined + mined
 - print("Minerals mined this run: "..mined)
 - print("Total mined: "..totalMined)
 - turtle.select(1)
 - turtle.turnRight()
 - turtle.turnRight()
 - end
 - -----------------------------------------------------------------------------
 - args = { ... }
 - term.clear()
 - term.setCursorPos(1,1)
 - print(" --- Mining program ---")
 - totalMined = 0 --Total mined out blocks
 - done = false --Whether turtle has completed
 - running = true --Whether turtle is currently digging
 - w, l, d = 0, 0, 0 --Width, length, depth of hole.
 - currentPos = {} --Current position storage. It's a table just because it is easier
 - currentPos.x, currentPos.y, currentPos.z, currentPos.f = 0, 0, 0, 0 --Initialise pieces of current position
 - edge = {} --Boundaries of hole. Same deal as currentpos
 - -- Directions
 - South, West, North, East, Up, Down = 0, 1, 2, 3, 4, 5
 - directionString = { South=0, West=1, North=2, East=3 }
 - local shortNames = {[North] = "N", [West] = "W", [South] = "S", [East] = "E", [Up] = "U", [Down] = "D" }
 - -- Get Startup Direction
 - currentPos.f = getDirection()
 - -- save current position as start/drop-zone, or even use already saved..
 - startPos = {}
 - if not fs.exists(".startzone") then
 - startPos.X, startPos.Y, startPos.Z = gps.locate(5,false)
 - startPos.F = currentPos.f
 - local file = fs.open(".startzone", "w")
 - file.write(textutils.serialize(startPos))
 - file.close()
 - else
 - local file = fs.open(".startzone", "r")
 - startPos = textutils.unserialize(file.readAll())
 - file.close()
 - end
 - -- Current coords:
 - x,y,z = gps.locate(5,false)
 - if not x or not y or not z then
 - error("Out of GPS range")
 - end
 - currentPos.x = x
 - currentPos.y = y
 - currentPos.z = z
 - -- last mining coords / mining taring coords:
 - xWork = x
 - yWork = y
 - zWork = z
 - --If a square hole is wanted
 - if #args == 2 and tonumber(args[1]) > 1 and tonumber(args[2]) > 2 then
 - --Width, length, depth of hole
 - w = tonumber(args[1])
 - l = w
 - d = tonumber(args[2])
 - --If a non-square hole is wanted
 - elseif #args == 3 and tonumber(args[1]) > 1 and tonumber(args[2]) > 1 and tonumber(args[3]) > 2 then
 - w = tonumber(args[1])
 - l = tonumber(args[2])
 - d = tonumber(args[3])
 - --If arguments improperly input, print usage
 - else
 - print("Usage: \"miner <side> <depth>\" or \"miner <width> <length> <depth>\"")
 - print("Note: depth must be at least 3.")
 - error()
 - end
 - --Edge locations
 - edge.x = w - 1
 - edge.y = -(d - 1)
 - edge.z = l - 1
 - print("Digging a hole "..w.." by "..l.." by "..d.." meters.")
 - -----------------------------------------------------------------------------------
 - function rt(ct)
 - ct = ct or 1
 - for i=1,ct do
 - turtle.turnRight()
 - f = (f+1)%4
 - end
 - return true
 - end
 - function lt(ct)
 - ct = ct or 1
 - for i=1,ct do
 - turtle.turnLeft()
 - f = (f+3)%4
 - end
 - return true
 - end
 - -- Receive an absolute directon and does the propiate turns
 - function face(d)
 - if type(d) == "string" then
 - dirs = {north=0, east=1, south=2, west=3}
 - d = dirs[d]
 - elseif type(d) == "number" then
 - if d < 0 or d > 4 then
 - error("Direction number out of range (0-3).",2)
 - end
 - end
 - if d == nil then error("No direction specified.",2) end
 - -- F 0=North, 1=East, 2=South, 3=West
 - -- South= +z, East= +x
 - local dir = -1
 - if dirString[d] ~= nil then
 - dir = dirString[d]
 - else
 - dir = d
 - end
 - if dir == 0 and f == 3 then
 - rt()
 - elseif dir == 3 and f == 0 then
 - lt()
 - elseif dir > f then
 - rt(dir - f)
 - elseif dir < f then
 - lt(f - dir)
 - end
 - end
 - function movX(tox)
 - -- Moves the turle to tox in X axix
 - if x > tox then
 - gira(0)
 - elseif x < tox then
 - gira(2)
 - end
 - while x ~= tox do
 - while turtle.detect() do
 - turtle.dig()
 - end
 - turtle.forward()
 - if lado == 0 then
 - x=x-1
 - else
 - x=x+1
 - end
 - end
 - end
 - function movY(toy)
 - -- Moves the turle to toy in Y axix
 - while y < toy do
 - if turtle.detectDown() then
 - turtle.digDown()
 - end
 - turtle.down()
 - y=y+1;
 - end
 - while y > toy do
 - while turtle.detectUp() do
 - turtle.digUp()
 - end
 - if turtle.up() then
 - y=y-1;
 - else
 - finaliza=true
 - break;
 - end
 - end
 - end
 - function movZ(toz)
 - -- Moves the turle to toz in Z axix
 - if z > toz then
 - gira(3)
 - elseif z < toz then
 - gira(1)
 - end
 - while z ~= toz do
 - while turtle.detect() do
 - turtle.dig()
 - end
 - turtle.forward()
 - if lado == 1 then
 - z=z+1
 - else
 - z=z-1
 - end
 - end
 - end
 - function mueveCords(tox,toy,toz,dir)
 - -- Moves the turtle to the spcified coords mining everithing in its way.
 - modY = 0
 - if dir == "home" then
 - if y-2 >= toy and y-2 >= minY then
 - modY=2
 - movY(y-modY)
 - end
 - -- x:
 - movX(tox)
 - -- z:
 - movZ(toz)
 - -- y:
 - movY(toy)
 - else
 - if y <= toy-2 and toy-2 >= minY then
 - modY=2;
 - end
 - movY(toy-modY)
 - -- z:
 - movZ(toz)
 - -- x:
 - movX(tox)
 - -- y:
 - movY(toy)
 - end
 - end
 - -- Checks the slots. If some slot is full, it will go home to drop everything
 - function checkInventory()
 - local tmp = 9
 - local full = false
 - while tmp > 0 do
 - if turtle.getItemSpace(tmp) == 64 then
 - full = true
 - else
 - tmp = tmp - 1
 - end
 - end
 - if full then
 - xWork = x
 - yWork = y
 - zWork = z
 - goHome()
 - descarga()
 - goWork()
 - end
 - end
 - -- Drops everithing
 - function descarga()
 - print("Dropping items...")
 - local tmp = 9
 - while tmp > 0 do
 - turtle.select(tmp)
 - if turtle.getItemCount(tmp) > 0 then
 - turtle.drop(turtle.getItemCount(tmp))
 - end
 - tmp = tmp - 1
 - end
 - end
 - ------------------------------------------ old
 - --Retrieve variables/Instantiate Values
 - local args = {...}
 - --First argument = how long tunnel is
 - local dist = tonumber(args[1])
 - --Second argument = What direction the tunnels go
 - local direct = tostring(args[2])
 - --Mines out blocks in front, above, left and right [Moves forward when clear]
 - local function mineTunnel()
 - if turtle.detect() then
 - turtle.dig()
 - end
 - if turtle.detectUp() then
 - turtle.digUp()
 - end
 - if turtle.turnLeft() then
 - turtle.dig()
 - turtle.turnRight()
 - end
 - if turtle.turnRight() then
 - turtle.dig()
 - turtle.turnLeft()
 - end
 - -- Digs until the turtle can move forward.
 - while not turtle.forward() do
 - turtle.dig()
 - turtle.digUp()
 - end
 - end
 - --Digs a tunnel given distance args[0] (requires args[0])
 - local function tunnel()
 - for i=1,dist,1 do
 - mineTunnel()
 - end
 - if direct == "left" then
 - turtle.turnLeft()
 - mineTunnel()
 - turtle.turnLeft()
 - end
 - if direct == "right" then
 - turtle.turnRight()
 - mineTunnel()
 - turtle.turnRight()
 - end
 - for i=1,dist,1 do
 - mineTunnel()
 - end
 - end
 - --Executes until told to stop
 - while true do
 - tunnel()
 - turtle.select(1)
 - turtle.dig()
 - turtle.place()
 - for slot=2,16,1 do
 - turtle.select(slot)
 - while turtle.getItemCount(slot) > 0 do
 - turtle.drop()
 - end
 - end
 - if direct == "left" then
 - turtle.turnRight()
 - end
 - if direct == "right" then
 - turtle.turnLeft()
 - end
 - turtle.dig()
 - turtle.forward()
 - turtle.digUp()
 - turtle.dig()
 - turtle.forward()
 - turtle.digUp()
 - turtle.dig()
 - turtle.forward()
 - turtle.digUp()
 - if direct == "left" then
 - turtle.turnRight()
 - end
 - if direct == "right" then
 - turtle.turnLeft()
 - end
 - end
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment