Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --AaronDMorgan's GPS Mining Turtle Program
- --Manually entered "end coordinates" will be changed to changeable Args in the future.
- --CURRENTLY MINES ONE TUNNEL FOR DEBUGGING PURPOSES!
- --function for leaving the ground
- function ymoveup()
- updist = 1
- repeat
- turtle.up()
- updist = updist - 1
- until updist == 0
- updist = 1
- end
- --function responsible for z-plane movement to chest
- function zmove()
- if z > 1033 then --Enter end z coordinate here
- zdist = z - 1033
- repeat
- turtle.forward()
- zdist = zdist - 1
- until zdist == 0
- end
- if z < 1033 then
- zdist = z - 1033
- zdist = zdist * -1
- turtle.turnRight()
- turtle.turnRight()
- repeat
- turtle.forward()
- zdist = zdist - 1
- until zdist == 0
- turtle.turnRight()
- turtle.turnRight()
- end
- turtle.turnLeft()
- end
- --function responsible for x-plane movement to chest
- function xmove()
- if x > 233 then -- enter end x coordinate here
- xdist = x - 233
- repeat
- turtle.forward()
- xdist = xdist - 1
- until xdist == 0
- end
- if x < 233 then
- xdist = x - 233
- xdist = xdist * -1
- turtle.turnRight()
- turtle.turnRight()
- repeat
- turtle.forward()
- xdist = xdist - 1
- until xdist == 0
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- --function responsible for landing
- function ymovedown()
- y = y + updist
- ydist = y - 11 --enter end y coordinate here
- repeat
- turtle.down()
- ydist = ydist - 1
- until ydist == 0
- turtle.turnRight()
- end
- --function responsible for z-plane movement back to mining
- function zmoveback()
- if z > zstart then
- zdist = z - zstart
- repeat
- turtle.forward()
- zdist = zdist - 1
- until zdist == 0
- end
- if z < zstart then
- zdist = z - zstart
- zdist = zdist * -1
- turtle.turnRight()
- turtle.turnRight()
- repeat
- turtle.forward()
- zdist = zdist - 1
- until zdist == 0
- turtle.turnRight()
- turtle.turnRight()
- end
- turtle.turnLeft()
- end
- --function responsible for x-plane movement back to mining
- function xmoveback()
- if x > xstart then
- xdist = x - xstart
- repeat
- turtle.forward()
- xdist = xdist - 1
- until xdist == 0
- end
- if x < xstart then
- xdist = x - xstart
- xdist = xdist * -1
- turtle.turnRight()
- turtle.turnRight()
- repeat
- turtle.forward()
- xdist = xdist - 1
- until xdist == 0
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- --[[Computer slot 1, Filter slot 2, Timer slot 3, Chest slot 4, Fuel slot 15, torches slot 16.]]
- -- Create the function for refueling
- function checkFuel()
- if turtle.getFuelLevel() <= 20 then
- if turtle.getItemCount(15) == 0 then
- print("Out of fuel.")
- exit()
- else
- turtle.select(15)
- turtle.refuel(1)
- turtle.select(1)
- end --if
- end --if
- end --checkFuel()
- -- Create the turnAround function
- function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end --turnAround()
- -- Digs the tunnel for the given length
- function tunnel(length)
- local torchDistance = 0
- d = 0
- while d <= 75 do --change to increase tunnel distance
- if turtle.detect() then
- repeat
- turtle.dig()
- sleep(0.50)
- until turtle.detect() == false
- end --if
- turtle.forward()
- if turtle.detectUp() then
- repeat
- turtle.digUp()
- sleep(0.50)
- until turtle.detectUp() == false
- end --if
- turtle.turnLeft()
- if turtle.detect() then
- repeat
- turtle.dig()
- sleep(0.50)
- until turtle.detect() == false
- end --if
- turtle.up()
- if turtle.detect() then
- repeat
- turtle.dig()
- sleep(0.50)
- until turtle.detect() == false
- end--if
- turtle.turnRight()
- turtle.turnRight()
- if turtle.detect() then
- repeat
- turtle.dig()
- sleep(0.50)
- until turtle.detect() == false
- end
- turtle.down()
- if turtle.detect() then
- repeat
- turtle.dig()
- sleep(0.50)
- until turtle.detect() == false
- end
- turtle.turnLeft()
- d = d + 1
- torchDistance = torchDistance + 1
- -- attempts to place a block below
- turtle.select(1)
- turtle.placeDown()
- -- Places a torch every 9 blocks
- if torchDistance == 9 then
- print("Placing torch...")
- turtle.select(16)
- turnAround()
- turtle.place()
- turnAround()
- torchDistance = 0
- checkFuel()
- end --if
- end --for
- -- Sends the turtle back to the start
- turtle.up()
- turnAround()
- for index = 1, d do
- checkFuel()
- if not turtle.detect() then
- turtle.forward()
- else
- repeat
- turtle.dig()
- turtle.sleep(0.25)
- until turtle.detect() == false
- turtle.forward()
- end --if
- end --for
- turtle.down()
- turnAround()
- end --tunnel()
- --function responsible for emptying inventory into chest
- function itemdump()
- turtle.select(1)
- turtle.drop()
- turtle.select(2)
- turtle.drop()
- turtle.select(3)
- turtle.drop()
- turtle.select(4)
- turtle.drop()
- turtle.select(5)
- turtle.drop()
- turtle.select(6)
- turtle.drop()
- turtle.select(7)
- turtle.drop()
- turtle.select(8)
- turtle.drop()
- turtle.select(9)
- turtle.drop()
- turtle.select(10)
- turtle.drop()
- turtle.select(11)
- turtle.drop()
- turtle.select(12)
- turtle.drop()
- turtle.select(13)
- turtle.drop()
- turtle.select(14)
- turtle.drop()
- turtle.select(15)
- turtle.drop()
- end --itemdump()
- -- Main script
- rednet.open("right")
- x, y, z = gps.locate()
- xstart, ystart, zstart = gps.locate()
- tunnel()
- ymoveup()
- zmove()
- xmove()
- ymovedown()
- itemdump()
- x, y, z = gps.locate()
- ymoveup()
- zmoveback()
- xmoveback()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- ymovedown()
Advertisement
Add Comment
Please, Sign In to add comment