Griffork

Mining v2.6

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