AlphaSheepPig

CC Turtle Branchmine

Jun 17th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. --[[
  2. branchmine v 1.0
  3. by AlphaSheepPig
  4.  
  5. To use, give the turtle the following:
  6. Slot 1: Coal
  7. Slot 2: Cobblestone
  8. Slot 3: Chests
  9. Slot 4: Torches
  10.  
  11. Turtle will dig a 2 high tunnel for
  12. 100 blocks, move 5 blocks over, and
  13. dig a second tunnel back.
  14. It places torches along the way,
  15. and places a chest and offloads
  16. inventory when full.
  17. ]]
  18.  
  19.  
  20. function placeTorch ()
  21.     turtle.turnLeft()
  22.     turtle.turnLeft()
  23.     turtle.select(4)
  24.     turtle.place()
  25.     turtle.turnLeft()
  26.     turtle.turnLeft()
  27. end    
  28.  
  29.  
  30. function offLoad ()
  31.     turtle.turnLeft()
  32.     repeat
  33.         sleep(0.5)
  34.     until turtle.dig() == false or turtle.detect() == false
  35.     turtle.forward()
  36.     repeat
  37.         sleep(0.5)
  38.     until turtle.digUp() == false or turtle.detectUp() == false
  39.     turtle.back()
  40.     turtle.select(3)
  41.     turtle.place()
  42.     for slot = 5,16,1 do
  43.         turtle.select(slot)
  44.         turtle.drop()
  45.     end    
  46.     turtle.select(5)
  47.     turtle.turnRight()
  48. end
  49.  
  50.  
  51. function moveOneBlock (i)
  52.     repeat
  53.         sleep(0.5)
  54.     until turtle.dig() == false or turtle.detect() == false
  55.     repeat
  56.         sleep(0.5)
  57.     until turtle.digUp() == false or turtle.detectUp() == false
  58.     turtle.select(2)
  59.     turtle.placeDown()
  60.     if i%13 == 0 then
  61.         placeTorch()
  62.     end
  63. end
  64.  
  65.  
  66. function checkMaterials()
  67.     for slot = 1,4,1 do
  68.         if turtle.getItemCount(slot) == 0 then
  69.             print("Out of materials")
  70.             exit()
  71.         end
  72.     end
  73. end
  74.  
  75.  
  76. function mineTunnel (length)
  77.     i = 1
  78.     while i < length do
  79.         moveOneBlock(i)    
  80.         if turtle.getFuelLevel() == 0 then
  81.             turtle.select(1)
  82.             turtle.refuel(1)
  83.         end
  84.         if turtle.getItemCount(16) > 0 then
  85.             offLoad()
  86.         end
  87.     if turtle.forward() then
  88.             i = i+1
  89.         end
  90.         checkMaterials()
  91.     end
  92. end
  93.  
  94.  
  95. function makeMine (x,y)
  96.     -- digs a tunnel x blocks, moves over y blocks, and digs a tunnel back.
  97.     mineTunnel(x)
  98.     placeTorch()
  99.     turtle.turnLeft()
  100.  
  101.     mineTunnel(y)
  102.     placeTorch()
  103.     turtle.turnLeft()
  104.  
  105.     mineTunnel(x)
  106.     placeTorch()
  107.     turtle.turnRight()
  108.  
  109.     mineTunnel(y)
  110.     placeTorch()
  111.     turtle.turnRight()
  112. end
  113.  
  114.  
  115. while true do
  116.     makeMine(50,4)
  117. end
Advertisement
Add Comment
Please, Sign In to add comment