David_Turtle

Turtle "Certus Miner"

Jan 15th, 2019 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.81 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. print("Certus Miner v.1.0")
  5. print("")
  6. print("Certus Erz spawnt auf Höhe 12 bis 74")
  7. print("Die Turtle gräbt ein 8x8 Loch nach unten")
  8. print("Certus Erz wird ignoriert")
  9. print("")
  10. print("Drücken sie Enter...")
  11. local temp = read()
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. print("Achtung!")
  15. print("")
  16. print("Slot 1 muss Certus Quartz Ore enthalten!")
  17. print("Slot 2 muss Charged Certus Quartz Ore enthalten!")
  18. print("Slot 3 muss Treibstoff enhalten!")
  19. print("")
  20. print("Wie tief graben?")
  21.  
  22. local length   = read()
  23. local left     = length
  24. local willDrop = false
  25. local normCert = false
  26. local charCert = false
  27. local skipNext = false
  28.  
  29. function checkFuel()
  30.     if turtle.getFuelLevel() < 15 then
  31.         turtle.select(3)
  32.         turtle.refuel()
  33.     end
  34. end
  35.  
  36. function digBlock()
  37.  
  38.     turtle.select(1)
  39.     normCert = turtle.compare()
  40.     turtle.select(2)
  41.     charCert = turtle.compare()
  42.  
  43.     if (not normCert and not charCert) then
  44.  
  45.         --delay mining due to gravel possibly falling in front of turtle
  46.         while turtle.detect() do
  47.  
  48.             turtle.dig()
  49.             os.sleep(0.5)
  50.  
  51.         end
  52.  
  53.     else
  54.  
  55.         skip()
  56.  
  57.     end
  58.  
  59. end  
  60.  
  61. function skip()
  62.  
  63.     turtle.select(1)
  64.     normCert = turtle.compare()
  65.     turtle.select(2)
  66.     charCert = turtle.compare()
  67.  
  68.     while(normCert or charCert) do
  69.  
  70.         turtle.digDown()
  71.         turtle.down()
  72.  
  73.         left = left-1  
  74.  
  75.         os.sleep(0.5)  
  76.  
  77.         turtle.select(1)
  78.         normCert = turtle.compare()
  79.         turtle.select(2)
  80.         charCert = turtle.compare()
  81.  
  82.     end
  83.  
  84.     digBlock()
  85.  
  86.     skipNext = true
  87.     status()
  88.  
  89. end
  90.  
  91. function status()
  92.     print("[Slot 1] Certus Quartz Ore")
  93.     print("[Slot 2] Charged Certus Quartz Ore")
  94.     print("[Slot 3] Treibstoff")
  95.     print("")
  96.     print("Schichten uebrig : "..left)
  97.     print("Treibstoff : "..turtle.getFuelLevel())
  98.  
  99.     if skipNext then
  100.    
  101.         print("")
  102.         print("Die nächste Schicht wird doppelt gegraben!")
  103.  
  104.     end
  105.  
  106. end
  107.  
  108. function dropRoutine()
  109.     willDrop = true
  110.  
  111.     for i=4,16 do
  112.         if(turtle.getItemCount(i) == 0) then
  113.             willDrop = false
  114.         end
  115.     end
  116.  
  117.     if(willDrop == true) then
  118.         term.clear()
  119.         term.setCursorPos(1,1)
  120.         print("")
  121.         print("Inventory full!")
  122.         print("Starting Drop Sub-Routine")
  123.         for i=4,16 do
  124.             data = turtle.getItemDetail(i)
  125.             turtle.select(i)
  126.             if data then
  127.                 print("Item name: ", data.name)
  128.                 print("Item count: ", data.count)
  129.    
  130.                 if(data.name == "minecraft:cobblestone") then
  131.                     turtle.drop(data.count)
  132.                     print("Dropped!")
  133.                 end
  134.                 if(data.name == "minecraft:dirt") then
  135.                     turtle.drop(data.count)
  136.                     print("Dropped!")
  137.                 end
  138.                 if(data.name == "minecraft:flint") then
  139.                     turtle.drop(data.count)
  140.                     print("Dropped!")
  141.                 end
  142.                 if(data.name == "minecraft:gravel") then
  143.                     turtle.drop(data.count)
  144.                     print("Dropped!")
  145.                 end
  146.                 if(data.name == "chisel:limestone") then
  147.                     turtle.drop(data.count)
  148.                     print("Dropped!")
  149.                 end
  150.                 if(data.name == "chisel:marble") then
  151.                     turtle.drop(data.count)
  152.                     print("Dropped!")
  153.                 end
  154.                 if(data.name == "minecraft:netherrack") then
  155.                     turtle.drop(data.count)
  156.                     print("Dropped!")
  157.                 end
  158.             else
  159.                 print("Empty")
  160.             end
  161.         end
  162.  
  163.         for loop = 0, 11 do
  164.             term.clear()
  165.             term.setCursorPos(1,1)
  166.  
  167.             print("Moving Items up...")
  168.             print("")
  169.  
  170.             print("Sub-Loop ", loop+1, "/ 13")
  171.             for i = 4, 15 do
  172.  
  173.                 turtle.select(i+1)
  174.                 data1 = turtle.getItemDetail(i)
  175.                 data2 = turtle.getItemDetail(i+1)
  176.  
  177.                 if(not data1 and data2) then
  178.  
  179.                     turtle.transferTo(i)
  180.  
  181.                 end
  182.  
  183.             end
  184.         end
  185.     end
  186.    
  187.     turtle.select(3)
  188.  
  189. end
  190.  
  191. function digLayer()
  192.  
  193.     for x=1,4 do
  194.        
  195.         for z=1,7 do
  196.        
  197.             digBlock()
  198.             turtle.forward()
  199.  
  200.         end
  201.            
  202.         turtle.turnRight()
  203.         digBlock()
  204.         turtle.forward()
  205.         turtle.turnRight()
  206.         status()
  207.  
  208.         for z=1,7 do
  209.        
  210.             digBlock()
  211.             turtle.forward()
  212.  
  213.         end
  214.  
  215.         if x < 4 then
  216.  
  217.             turtle.turnLeft()
  218.             digBlock()
  219.             turtle.forward()
  220.             turtle.turnLeft()
  221.  
  222.             status()
  223.  
  224.         end
  225.  
  226.     end
  227.  
  228.     dropRoutine()
  229.  
  230. end
  231.  
  232. for i=1, length do
  233.  
  234.     term.clear()
  235.     term.setCursorPos(1,1)
  236.     checkFuel()
  237.     status()
  238.     digLayer()
  239.  
  240.     if not skipNext then
  241.  
  242.         turtle.digDown()
  243.         turtle.down()
  244.  
  245.         left = left-1
  246.  
  247.     else
  248.  
  249.         skipNext = false
  250.  
  251.     end
  252.  
  253.     turtle.turnRight()
  254.  
  255. end
  256.  
  257. term.clear()
  258. term.setCursorPos(1,1)
  259. checkFuel()
  260. status()
  261. print("Fertig!")
Advertisement
Add Comment
Please, Sign In to add comment