David_Turtle

Turtle "Minen 2.0"

Nov 30th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.83 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. print("Turtle Miner v.1.3")
  5. print("")
  6. print("Die Turtle wird einen 3x3 Gang graben")
  7. print("Wie lange graben?")
  8.  
  9. local length = read()
  10. local torch = 0
  11. local left = length
  12. local willDrop = false
  13.  
  14. function checkFuel()
  15.     if turtle.getFuelLevel() < 15 then
  16.         turtle.select(1)
  17.         turtle.refuel()
  18.     end
  19. end
  20. function digBlock()
  21.     while turtle.detect() do
  22.         turtle.dig()
  23.     end
  24. end
  25. function digBlockUp()
  26.     while turtle.detectUp() do
  27.         turtle.digUp()
  28.     end
  29. end
  30. function status()
  31.     print("[Slot 1] Treibstoff   [Slot 2] Fackeln")
  32.     print("")
  33.     print("Reihen uebrig : "..left)
  34.     print("Treibstoff : "..turtle.getFuelLevel())
  35. end
  36.  
  37. function dropRoutine()
  38.     willDrop = true
  39.  
  40.     for i=3,16 do
  41.         if(turtle.getItemCount(i) == 0) then
  42.             willDrop = false
  43.         end
  44.     end
  45.  
  46.     if(willDrop == true) then
  47.         term.clear()
  48.         term.setCursorPos(1,1)
  49.         print("")
  50.         print("Inventory full!")
  51.         print("Starting Drop Sub-Routine")
  52.         for i=3,16 do
  53.             data = turtle.getItemDetail(i)
  54.             turtle.select(i)
  55.             if data then
  56.                 print("Item name: ", data.name)
  57.                 print("Item count: ", data.count)
  58.    
  59.                 if(data.name == "minecraft:cobblestone") then
  60.                     turtle.drop(data.count)
  61.                     print("Dropped!")
  62.                 end
  63.                 if(data.name == "minecraft:dirt") then
  64.                     turtle.drop(data.count)
  65.                     print("Dropped!")
  66.                 end
  67.                 if(data.name == "minecraft:gravel") then
  68.                     turtle.drop(data.count)
  69.                     print("Dropped!")
  70.                 end
  71.                 if(data.name == "chisel:limestone") then
  72.                     turtle.drop(data.count)
  73.                     print("Dropped!")
  74.                 end
  75.                 if(data.name == "chisel:marble") then
  76.                     turtle.drop(data.count)
  77.                     print("Dropped!")
  78.                 end
  79.                 if(data.name == "minecraft:netherrack") then
  80.                     turtle.drop(data.count)
  81.                     print("Dropped!")
  82.                 end
  83.             else
  84.                 print("Empty")
  85.             end
  86.         end
  87.  
  88.         for loop = 0, 12 do
  89.             term.clear()
  90.             term.setCursorPos(1,1)
  91.  
  92.             print("Moving Items up...")
  93.             print("")
  94.  
  95.             print("Sub-Loop ", loop+1, "/ 13")
  96.             for i = 3, 15 do
  97.  
  98.                 turtle.select(i+1)
  99.                 data1 = turtle.getItemDetail(i)
  100.                 data2 = turtle.getItemDetail(i+1)
  101.  
  102.                 if(not data1 and data2) then
  103.  
  104.                     turtle.transferTo(i)
  105.  
  106.                 end
  107.  
  108.             end
  109.         end
  110.     end
  111.    
  112.     turtle.select(3)
  113.  
  114. end
  115.  
  116. dropRoutine()
  117.  
  118. function digLayer()
  119.     for i=1,2 do
  120.         turtle.turnLeft()
  121.         digBlock()
  122.         turtle.turnRight()
  123.         turtle.turnRight()
  124.         digBlock()
  125.         turtle.turnLeft()
  126.         digBlockUp()
  127.         turtle.up()
  128.     end
  129.     turtle.turnLeft()
  130.     digBlock()
  131.     turtle.turnRight()
  132.     turtle.turnRight()
  133.     digBlock()
  134.     if torch == 8 then
  135.         turtle.forward()
  136.         turtle.turnRight()
  137.         turtle.forward()
  138.         turtle.select(2)
  139.         turtle.placeDown()
  140.         turtle.back()
  141.         turtle.turnLeft()
  142.         turtle.back()
  143.         torch = 0
  144.     end
  145.     turtle.turnLeft()
  146.     turtle.down()
  147.     turtle.down()
  148.     torch = torch + 1
  149.     left = left - 1
  150.  
  151.     dropRoutine()
  152.  
  153. end
  154.  
  155. for i=1,length do
  156.     turtle.dig()
  157.     turtle.forward()
  158.     term.clear()
  159.     term.setCursorPos(1,1)
  160.     checkFuel()
  161.     status()
  162.     digLayer()
  163. end
  164.  
  165. term.clear()
  166. term.setCursorPos(1,1)
  167. checkFuel()
  168. status()
  169. turtle.turnRight()
  170. turtle.turnRight()
  171. for i=0,length-3 do
  172.     turtle.forward()
  173. end
  174.  
  175. term.clear()
  176. term.setCursorPos(1,1)
  177. checkFuel()
  178. status()
  179. print("Fertig!")
Advertisement
Add Comment
Please, Sign In to add comment