Advertisement
Treyzania

SuperExcavate (DON'T STEAL IT!)

Nov 3rd, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. args = {...}
  2.  
  3. --== CONFIG ==--
  4.  
  5. dumpChestSlot = 1
  6. fuelChestSlot = 2
  7. firstLoadSlot = 3
  8. lastLoadSlot = 16
  9.  
  10. chunkSize = 8 -- Measured in blocks on each side.
  11. pillarHeight = 10
  12. spaceBetweeenChunks = 2
  13. minimumFuelLevel = 1000
  14.  
  15. --== END OF CONFIG ==--
  16.  
  17. dugBlocks = 0
  18. skipped = tonumber(args[1]) or 0
  19.  
  20. function dug(actually)
  21.  
  22.   if actually then dugBlocks = dugBlocks + 1 end
  23.  
  24.   term.setCursorPos(1, 1)
  25.   print("Blocks Dug: " .. dugBlocks)
  26.   print("Fuel Level: " .. turtle.getFuelLevel())
  27.  
  28. end
  29.  
  30. function dig()
  31.   did = turtle.detect()
  32.   turtle.dig()
  33.   while turtle.detect() do turtle.dig() sleep(1) end
  34.   dug(did)
  35. end
  36.  
  37. function digUp()
  38.   did = turtle.detectUp()
  39.   turtle.digUp()
  40.   while turtle.detectUp() do turtle.digUp() sleep(1) end
  41.   dug(did)
  42. end
  43.  
  44. function digDown()
  45.   did = turtle.detectDown()
  46.   turtle.digDown()
  47.   while turtle.detectDown() do turtle.digDown() sleep(1) end
  48.   dug(did)
  49. end
  50.  
  51. function fwd()
  52.   dig()
  53.   turtle.forward()
  54. end
  55.  
  56. function dwn()
  57.   digDown()
  58.   turtle.down()
  59. end
  60.  
  61. function dumpLoad()
  62.  
  63.   turtle.select(dumpChestSlot)
  64.   digUp()
  65.   turtle.placeUp()
  66.  
  67.   for i = firstLoadSlot, lastLoadSlot do
  68.    
  69.     turtle.select(i)
  70.     turtle.dropUp()
  71.    
  72.   end
  73.  
  74.   turtle.select(dumpChestSlot)
  75.   digUp()
  76.  
  77.   turtle.select(firstLoadSlot)
  78.  
  79. end
  80.  
  81. function refuel() -- Doesn't refuel if it doesn't have to.
  82.  
  83.   fuelLevel = turtle.getFuelLevel()
  84.  
  85.   if fuelLevel < minimumFuelLevel then
  86.    
  87.     turtle.select(fuelChestSlot)
  88.     digUp()
  89.     turtle.placeUp()
  90.    
  91.     turtle.suckUp()
  92.     turtle.refuel()
  93.    
  94.     digUp()
  95.     turtle.select(firstLoadSlot)
  96.    
  97.   end
  98.  
  99. end
  100.  
  101. function pillar()
  102.  
  103.   for i = 1, pillarHeight do -- Down...
  104.     dwn()
  105.   end
  106.  
  107.   for i = 1, pillarHeight do -- ...and back up!
  108.     turtle.up()
  109.   end
  110.  
  111.   dumpLoad()
  112.   refuel()
  113.  
  114. end
  115.  
  116. function chunk()
  117.  
  118.   for i = 1, chunkSize do
  119.    
  120.     for j = 1, chunkSize do -- Out...
  121.      
  122.       fwd()
  123.      
  124.       if skipped == 0 then
  125.         pillar()
  126.       else
  127.         skipped = skipped - 1
  128.       end
  129.      
  130.     end
  131.    
  132.     turtle.turnRight()
  133.     fwd()
  134.     turtle.turnRight()
  135.    
  136.     for j = 1, chunkSize do -- ...and return!
  137.       fwd()
  138.     end
  139.    
  140.     if i ~= chunkSize then
  141.       turtle.turnLeft()
  142.       turtle.turnLeft()
  143.     end
  144.    
  145.   end
  146.  
  147. end
  148.  
  149. function chunkAndMove()
  150.  
  151.   chunk()
  152.  
  153.   turtle.turnLeft()
  154.  
  155.   for i = 1, spaceBetweeenChunks do
  156.     fwd()
  157.   end
  158.  
  159.   turtle.turnLeft()
  160.  
  161. end
  162.  
  163. function loop()
  164.  
  165.   while true do
  166.    
  167.     chunkAndMove()
  168.    
  169.   end
  170.  
  171. end
  172.  
  173. term.clear()
  174. term.setCursorPos(1, 1)
  175.  
  176. dug(false)
  177.  
  178. dumpLoad()
  179. refuel()
  180.  
  181. turtle.select(firstLoadSlot)
  182. loop() -- It all comes together!
  183.  
  184. -- End of file.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement