Elgskred

dqwdqwd

Jul 12th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. startX = 0
  2. startY = 0
  3. startZ = 0
  4. currX = 0
  5. currY = 0
  6. currZ = 0
  7.  
  8. clearLength = 0
  9. clearWidth = 0
  10. clearHeight = 0
  11. EstFuel = 0
  12. running = 0
  13.  
  14. function UserInputs()
  15.  
  16. term.clear()
  17. term.setCursorPos(1, 1)
  18. print("Specify the length to clear out")
  19. clearLength = read()
  20. print("Specify the width to clear out")
  21. clearWidth = read()
  22. print("Specify the heigh to clear out")
  23. clearHeight = read()
  24. end
  25.  
  26. function StartFuel()
  27.     EstFuel = (clearLength * clearHeight * clearWidth)
  28.     print(EstFuel)
  29.         for i = 1, 16 do
  30.             turtle.select(i)
  31.             turtle.refuel()
  32.         end
  33.     print(turtle.getFuelLevel())
  34. end
  35.  
  36. function MoveForward()
  37.  while not turtle.forward() do
  38.        if turtle.detect() then
  39.                         if peripheral.isPresent("front") then
  40.                                 break
  41.                         else
  42.                                 turtle.dig()
  43.                                 if turtle.detect() then
  44.                                         sleep(1)
  45.                                         turtle.dig()
  46.                                 end
  47.                         end
  48.                 else
  49.                         turtle.attack()
  50.                 end
  51.         end
  52.  
  53.  
  54. end
  55.  
  56. function MoveUp()
  57. while not turtle.up() do
  58.        if turtle.detectUp() then
  59.                         turtle.digUp()
  60.                                 if turtle.detectUp() then
  61.                                         sleep(1)
  62.                                         turtle.digUp()
  63.                                 end
  64.                 else
  65.                         turtle.attackUp()
  66.                 end
  67.         end
  68.  
  69.  
  70. end
  71.  
  72. function MoveDown()
  73.  
  74. if Bedrock == 0 then
  75.         while not turtle.down() do
  76.        if turtle.detectDown() then
  77.                         turtle.digDown()
  78.                         print("Dig down: ok")
  79.                                 if turtle.detectDown() then
  80.                                         print("Detected something again")
  81.                                         sleep(1)
  82.                                         turtle.digDown()
  83.                                         if turtle.detectDown() then
  84.                                         Bedrock = 1
  85.                                         print("Bedrock is found")
  86.                                         GoHome()
  87.                                         end    
  88.                                 end
  89.                 else
  90.                 print("Something is still here, trying to attack")
  91.                 turtle.attackDown()            
  92.                 end
  93.         end
  94. end
  95. end
  96.  
  97. function DigUp()
  98.  
  99. while turtle.detectUp() do
  100.         turtle.digUp()
  101.         if turtle.detectUp() then
  102.                 turtle.digUp()
  103.                 sleep(1)
  104.                 if turtle.detectUp() then
  105.                         turtle.attackUp()
  106.                 end
  107.                
  108.         end
  109. end
  110.  
  111. end
  112.  
  113. function DigDown()
  114. while turtle.detectDown() do
  115.         turtle.digDown()
  116.         if turtle.detectDown() then
  117.                 turtle.digDown()
  118.                 sleep(1)
  119.                 turtle.digDown()
  120.                 if turtle.detectDown() then
  121.                         print("Bedrock underneath, breaking loop")
  122.                         Bedrock = 1
  123.                 end
  124.         else  
  125.                 turtle.attackDown()            
  126.         end
  127.        
  128. end
  129.  
  130. end
  131.  
  132.  
  133. UserInputs()
  134. StartFuel()
  135.  
  136. for i = 1, clearHeight/2 do
  137.  
  138.     for i = 1, clearWidth do
  139.    
  140.         for i = 1, clearLength do
  141.             DigUp()
  142.             MoveForward()
  143.             currX = currX + 1
  144.         end
  145.    
  146.     turtle.turnRight()
  147.     DigUp()
  148.     MoveForward()
  149.     currY = currY + 1
  150.     turtle.turnRight()
  151.        
  152.         for i = 1, clearLength do
  153.             DigUp()
  154.             MoveForward()
  155.             currX = currX - 1
  156.         end
  157.    
  158.     turtle.turnLeft()
  159.     DigUp()
  160.     MoveForward()
  161.     currY = currY + 1
  162.     turtle.turnLeft()
  163.    
  164.     end
  165.    
  166.     turtle.turnLeft()
  167.    
  168.     for i = 1, clearWidth do
  169.         DigUp()
  170.         MoveForward()
  171.         currY = currY - 1
  172.     end
  173.     DigUp()
  174.     MoveUp()
  175.     DigUp()
  176.     MoveUp()
  177.     turtle.turnRight()
  178.  
  179. end
  180.  
  181. running = 1
Advertisement
Add Comment
Please, Sign In to add comment