Advertisement
Bendix

Abbau

Aug 25th, 2020
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.68 KB | None | 0 0
  1. print("37-56 - 19 breit")
  2. print("46 weit")
  3.  
  4. print("in 1 den Treibstoff")
  5. print("in 2 die Fackeln")
  6. print("wie weit?")
  7. weit = io.read()
  8. print("wieviel zusaetzlich nach oben?")
  9. print("3+")
  10. hoch=0+ io.read()
  11. print("wie breit?")
  12. breit= io.read()
  13.  
  14.  
  15. function inspectDown()
  16. local successDown, dataDown = turtle.inspectDown()
  17. --if successDown then print("Unten:", dataDown.name) end
  18. return dataDown.name
  19. end
  20. function inspectUp()
  21. local successUp, dataUp = turtle.inspectUp()
  22. --if successUp then print("Oben:", dataUp.name) end
  23. return dataUp.name
  24. end
  25. function inspectFront()
  26. local successFront, dataFront =  turtle.inspect()
  27. --if successFront then print("Vorne:", dataFront.name) end
  28. return dataFront.name
  29. end
  30.  
  31. function inspect()
  32. inspectUp()
  33. inspectDown()
  34. inspectFront()
  35. end
  36.  
  37.  
  38.  
  39.  
  40.  
  41. --print(dataDown.name)
  42. --print(dataDown.metadata)
  43. --print(dataUp.name)
  44. --print(dataUp.metadata)
  45. --print(dataFront.name)
  46. --print(dataFront.metadata)
  47.  
  48. --if dataDown.name == "minecraft:stone" then
  49. --  turtle.select(16)
  50. --  turtle.digDown()
  51. --  turtle.drop()
  52. --end
  53. function digUp()
  54.   ergebnis = inspectUp()
  55.   if turtle.getItemCount(16) == 0 then
  56.     if ergebnis == "minecraft:stone" or ergebnis== "minecraft:dirt" or ergebnis=="minecraft:cobblestone" or ergebnis=="minecraft:gravel" then
  57.       turtle.select(16)
  58.       while turtle.detectUp() == true do
  59.         turtle.digUp()
  60.         turtle.attack()
  61.         sleep(0.5)
  62.         turtle.drop()
  63.       end
  64.       turtle.drop()
  65.     else
  66.       turtle.select(3)
  67.       turtle.digUp()
  68.     end
  69.   end
  70.  -- print("DigUp ", ergebnis)
  71. end
  72.  
  73. function digFront()
  74.   ergebnis = inspectFront()
  75.   if turtle.getItemCount(16) == 0 then
  76.     if ergebnis == "minecraft:stone" or ergebnis== "minecraft:dirt" or ergebnis=="minecraft:cobblestone" or ergebnis=="minecraft:gravel" then
  77.       turtle.select(16)
  78.       while turtle.detect() == true do
  79.         turtle.dig()
  80.         turtle.attack()
  81.         sleep(0.5)
  82.         turtle.drop()
  83.       end
  84.       turtle.drop()
  85.     else
  86.       turtle.select(3)
  87.       turtle.dig()
  88.     end
  89.   end
  90. --  print("digFront ", ergebnis)
  91. end
  92.  
  93. function digDown()
  94.   ergebnis = inspectDown()
  95.   if turtle.getItemCount(16) == 0 then
  96.     if ergebnis == "minecraft:stone" or ergebnis== "minecraft:dirt" or ergebnis=="minecraft:cobblestone" or ergebnis=="minecraft:gravel" then
  97.       turtle.select(16)
  98.       while turtle.detectDown() == true do
  99.         turtle.digDown()
  100.         turtle.attack()
  101.         sleep(0.5)
  102.         turtle.drop()
  103.       end
  104.       turtle.drop()
  105.     else
  106.       Fackel = inspectDown()
  107.       if Fackel ~= "minecraft:torch" then
  108.         turtle.select(3)
  109.         turtle.digDown()
  110.       end
  111.     end
  112.   end
  113. --  print("digDown ", ergebnis)
  114. end
  115.  
  116.  
  117.  
  118. if turtle.getItemCount(16) ~= 0 then turtle.select(16) turtle.drop() end
  119.  
  120. function fuel()
  121.   while turtle.getFuelLevel() < 500 do
  122.     turtle.select(1)
  123.     turtle.refuel(1)
  124.     print(turtle.getFuelLevel())
  125.   end
  126. end
  127. function forward()
  128.   while turtle.forward() == false do
  129.     digFront()
  130.     turtle.attack()
  131.   end
  132. end
  133. function unload()
  134.   for x=3,16 do
  135.     turtle.select(x)
  136.     turtle.dropDown()
  137.   end
  138.     fuel()
  139. end
  140.  
  141. function torch()
  142.   turtle.select(2)
  143.   turtle.placeDown()
  144.   print("torch")
  145. end
  146.  
  147.  
  148. for y=1,breit do
  149.  
  150.   for x=1,weit do
  151.  
  152.     -- abstand 11 pro reihe
  153.     -- nach 6 reihen neu setzten um 6 verschoben
  154.     -- 1 13 25 37 -> bei 0 angefangen alle 12 --> modulo X-1 == 12
  155.     -- 6 18 30 42 -> bei 6 angefangen alle 12 --> modulo X+5 == 12
  156.     -- modulo y
  157.    
  158.     digUp()
  159.     if x==1 then
  160.     print("kiste unter mir")
  161.     else
  162.     digDown()
  163.     end
  164.     digFront()
  165.    
  166. -------------------------------------------------  
  167. -- um zu verhindern, dass bei reihe 12 die reihe 12 und 6 bearbeitet wird (fackelverschwendung) müssen die If abfragen verschachtelt werden
  168. -- wenn durch 12 teilbar dann blabla elseif wenn durch 6 Teilbar
  169. -- Syntax:
  170. -- if bolean then
  171. -- else if bolean then
  172. -- end
  173.  
  174.     if (y-1)%12 == 0 then
  175.       if (x-1)%12 == 0  or x==6 then
  176.         torch()
  177.       end
  178.     elseif (y-1)%6 == 0 then
  179.       if (x-1)%12 == 0 or x==2 then
  180.         torch()
  181.       end
  182.     end
  183. --------------------------------------------------
  184.    
  185.    
  186.     forward()
  187.     weitgekommen = x
  188.    
  189.     turtle.select(3)
  190.   end
  191.   digUp()
  192.   digDown()
  193.   digFront()
  194.  
  195.   turtle.turnLeft()
  196.   turtle.turnLeft()
  197.   -- gang zurück
  198.   for x=1, weitgekommen do
  199.     forward()
  200.   end
  201.   turtle.turnLeft()
  202.   for z=1,y-1 do
  203.     -- print(y)
  204.     forward()
  205.   end
  206.   kiste =  inspectDown()
  207.   if kiste == "minecraft:chest" then
  208.     unload()
  209.   end
  210.   turtle.turnRight()
  211.   turtle.turnRight()
  212.   for z=1,y do
  213.       forward()
  214.       kiste =  inspectDown()
  215.       if kiste ~= "minecraft:chest" then
  216.       digDown()
  217.       end
  218.   end
  219.   turtle.turnRight()
  220. end
  221.   turtle.turnRight()
  222. for z=1,breit do
  223.   forward()
  224. end
  225. turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement