Griffork

Mining v 2.1

Dec 4th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. near=true
  2. blocksTravelled = 0
  3.  
  4. function detectLava()
  5.     turtle.up()
  6.     for i=0, 2, 1 do
  7.         if not turtle.detectUp() then
  8.             if turtle.digUp() then
  9.                 turtle.placeUp()
  10.             end
  11.         end
  12.         turtle.turnLeft()
  13.         if not turtle.detect() then
  14.             if turtle.dig() then
  15.                 turtle.place()
  16.             end
  17.         end
  18.         turtle.turnRight()
  19.         turtle.turnRight()
  20.         if not turtle.detect() then
  21.             if turtle.dig() then
  22.                 turtle.place()
  23.             end
  24.         end
  25.         if i == 0 then
  26.             turtle.down()
  27.         end
  28.     end
  29. end
  30.  
  31. function mine(num)
  32.     for i=0, num, 1 do
  33.         while turtle.detectUp() do
  34.             turtle.digUp()
  35.         end
  36.         while turtle.detect() do
  37.             turtle.dig()
  38.         end
  39.         while not turtle.forward() do
  40.             turtle.dig()
  41.         end
  42.         detectLava()
  43.     end
  44. end
  45.  
  46. function checkInventory()
  47.     if turtle.getItemCount(8) > 0 then
  48.         dropOff()
  49.     end
  50. end
  51.  
  52. function dropOff()
  53.     turtle.turnRight()
  54.     turtle.turnRight()
  55.     for i=0, (blocksTravelled - 1), 1 do
  56.         turtle.forward()
  57.     end
  58.     if not near then
  59.         turtle.turnLeft()
  60.         for i=0, 16, 1 do
  61.             turtle.forward()
  62.         end
  63.         turtle.turnRight()
  64.     end
  65.     sleep(10)
  66.     turtle.turnRight()
  67.     turtle.turnRight()
  68.     if not near then
  69.         turtle.turnLeft()
  70.         for i=0, 16, 1 do
  71.             turtle.forward()
  72.         end
  73.         turtle.turnRight()
  74.     end
  75.     for i=0, blocksTravelled - 1, 1 do
  76.         turtle.forward()
  77.     end
  78. end
  79.  
  80. function segment(mirror)
  81.     turn = function() error("Turn not being assigned") end
  82.     reverseTurn = function() error("ReverseTurn not being assigned") end
  83.     if mirror == true then
  84.         turn = turtle.turnRight
  85.         reverseTurn = turtle.turnLeft
  86.     else
  87.         turn = turtle.turnLeft
  88.         reverseTurn = turtle.turnRight
  89.     end
  90.     turn()
  91.     mine(16)
  92.     near = not near
  93.     turn()
  94.     mine(2)
  95.     reverseTurn()
  96.     reverseTurn()
  97.     mine(5)
  98.     blocksTravelled = blocksTravelled + 3
  99.     checkInventory()
  100. end
  101.    
  102. for i=0, 10, 1 do
  103.     segment(false)
  104.     segment(true)
  105. end
Advertisement
Add Comment
Please, Sign In to add comment