Advertisement
Florian86

mine

May 13th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.01 KB | None | 0 0
  1. function compactInv()
  2.     for checkSlot = 1, 16 do
  3.         if turtle.getItemCount(checkSlot) > 0 then
  4.             turtle.select(checkSlot)
  5.             for testSlot = checkSlot, 16 do
  6.                 if turtle.compareTo(testSlot) then
  7.                     turtle.select(testSlot)
  8.                     turtle.transferTo(checkSlot, turtle.getItemCount(testSlot))
  9.                     turtle.select(checkSlot)
  10.                 end
  11.             end
  12.         end
  13.     end
  14. end
  15.  
  16. function cleanUp()
  17.     for checkSlot = 16, 1, -1 do
  18.         while turtle.getItemCount(checkSlot) > 0 do
  19.             moveSlot = 16
  20.             turtle.select(checkSlot)
  21.             while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do
  22.                 moveSlot = moveSlot - 1
  23.             end
  24.             if moveSlot == checkSlot then
  25.                 break
  26.             end
  27.         end
  28.     end
  29. end
  30.  
  31. function sortInv()
  32.     for checkSlot = 16, 1, -1 do
  33.         if turtle.getItemCount(checkSlot) > 0 then
  34.             turtle.select(checkSlot)
  35.             moveSlot = 1
  36.             while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do
  37.                 moveSlot = moveSlot + 1
  38.             end
  39.             turtle.select(moveSlot)
  40.             for testSlot = 16, 1, -1 do
  41.                 moveSlot2 = moveSlot
  42.                 if testSlot > moveSlot2 then
  43.                     if turtle.getItemCount(testSlot) > 0 then
  44.                         if turtle.compareTo(testSlot) then
  45.                             turtle.select(testSlot)
  46.                             while not turtle.transferTo(moveSlot2, turtle.getItemCount(testSlot)) do
  47.                                 moveSlot2 = moveSlot2 + 1
  48.                             end
  49.                             turtle.select(moveSlot)
  50.                         end
  51.                     end
  52.                 end
  53.             end
  54.         end
  55.     end
  56. end
  57.  
  58. function Aufraeumen()
  59.   compactInv()
  60.   cleanUp()
  61.   sortInv()
  62. end
  63.  
  64. function IstInvVoll()
  65.     for slot=1,16 do
  66.         if turtle.getItemCount(slot)<1 then
  67.             return false
  68.         end
  69.     end
  70.     return true
  71. end
  72.  
  73. function SucheItem(VollerItemname)
  74.     for p=1,16 do
  75.         if turtle.getItemCount(p) > 0 then
  76.             turtle.select(p)
  77.             data=turtle.getItemDetail()
  78.             --print("data: ",data)
  79.             --print("data.name: ",data.name)
  80.             --print("VollerItemname: ",VollerItemname)
  81.             --print("Slot: ", p)
  82.             if data ~= false then
  83.                 if data.name == VollerItemname then
  84.                     --print("Hat geklappt")
  85.                     found=true
  86.                     slot=tonumber(p)
  87.                     return slot
  88.                 end
  89.                 if data.name == "minecraft:"..VollerItemname then
  90.                     --print("Hat geklappt")
  91.                     found=true
  92.                     slot=tonumber(p)
  93.                     return slot
  94.                 end
  95.             end
  96.         end
  97.     end
  98.     return false
  99. end
  100.  
  101. function BlockVorTurtle()
  102.     success, data = turtle.inspect()
  103.     if success==true then
  104.       --print("Block name: ", data.name)
  105.       --print("Block metadata: ", data.metadata)
  106.       return data.name
  107.     else
  108.       return false
  109.     end
  110. end
  111.  
  112. function BlockUnterTurtle()
  113.     success, data = turtle.inspectDown()
  114.     if success==true then
  115.       --print("Block name: ", data.name)
  116.       --print("Block metadata: ", data.metadata)
  117.       return data.name
  118.     else
  119.       return false
  120.     end
  121. end
  122.  
  123. function BlockUeberTurtle()
  124.     success, data = turtle.inspectUp()
  125.     if success==true then
  126.       --print("Block name: ", data.name)
  127.       --print("Block metadata: ", data.metadata)
  128.       return data.name
  129.     else
  130.       return false
  131.     end
  132. end
  133.  
  134. function SeheUndMache()
  135.     vort=BlockVorTurtle()
  136.     untert=BlockUnterTurtle()
  137.     uebert=BlockUeberTurtle()
  138.    
  139.     if  vort~= false then
  140.         if vort == "minecraft:lava" then
  141.             EntferneLava("Vor")
  142.         end
  143.     end
  144.    
  145.     if  untert~= false then
  146.         if untert == "minecraft:lava" then
  147.             EntferneLava("Unten")
  148.         end
  149.     end
  150.    
  151.     if uebert~= false then
  152.         if uebert == "minecraft:lava" then
  153.             EntferneLava("Oben")
  154.         end
  155.     end
  156. end
  157.  
  158. function FahreVor()
  159.     SeheUndMache()
  160.     while not turtle.forward() do
  161.         sleep(1)
  162.     end
  163. end
  164.  
  165. function FahreZurueck()
  166.     SeheUndMache()
  167.     while not turtle.back() do
  168.         sleep(1)
  169.     end
  170. end
  171.  
  172. function FahreHoch()
  173.     SeheUndMache()
  174.     while not turtle.up() do
  175.         sleep(1)
  176.     end
  177. end
  178.  
  179. function FahreRunter()
  180.     SeheUndMache()
  181.     while not turtle.down() do
  182.         sleep(1)
  183.     end
  184. end
  185.  
  186. function GrabeVor()
  187.     while turtle.detect()==true do
  188.         turtle.dig()
  189.         os.sleep(0.5)
  190.     end
  191. end
  192.  
  193. function GrabeRunter()
  194.     turtle.digDown()
  195. end
  196.  
  197. function GrabeHoch()
  198.     while turtle.detectUp()==true do
  199.         turtle.digUp()
  200.         os.sleep(0.5)
  201.     end
  202. end
  203.  
  204. function SucheBauMaterial()
  205.     matz={"dirt", "cobblestone", "limestone", "netherrack", "soulsand", "netherbrick"}
  206.     for i=1, #matz do
  207.         test=SucheItem(matz[i])
  208.         if test ~= false then
  209.             if test > 0 and test < 17 then
  210.                 return test
  211.             end
  212.         end
  213.     end
  214.     return false
  215. end
  216.  
  217. function EntferneLava(wo)
  218.     sleep(0.5)
  219.     lavaeimer=SucheItem("lava_bucket")
  220.     if lavaeimer ~= false then
  221.         if lavaeimer > 0 and lavaeimer < 17 then
  222.             turtle.select(lavaeimer)
  223.             turtle.refuel()
  224.         end
  225.     end
  226.    
  227.     eimer=SucheItem("bucket")
  228.     if eimer ~= false then
  229.         if eimer > 0 and eimer < 17 then
  230.             turtle.select(eimer)
  231.             if wo == "Vor" then
  232.                 turtle.place()
  233.             elseif wo == "Oben" then
  234.                 turtle.placeUp()
  235.             elseif wo == "Unten" then
  236.                 turtle.placeDown()
  237.             end
  238.             sleep(0.5)
  239.             lavaeimer=SucheItem("lava_bucket")
  240.             if lavaeimer ~= false then
  241.                 if lavaeimer > 0 and lavaeimer < 17 then
  242.                     turtle.select(lavaeimer)
  243.                     turtle.refuel()
  244.                 end
  245.             end
  246.         end
  247.     else
  248.         materialslot=SucheBauMaterial()
  249.         if materialslot ~= false then
  250.             turtle.select(materialslot)
  251.             if wo == "Vor" then
  252.                 turtle.place()
  253.                 GrabeVor()
  254.             elseif wo == "Oben" then
  255.                 turtle.placeUp()
  256.                 GrabeHoch()
  257.             elseif wo == "Unten" then
  258.                 turtle.placeDown()
  259.                 GrabeRunter()
  260.             end
  261.         end
  262.     end
  263. end
  264.  
  265. function BaueBoden()
  266.     if not turtle.detectDown() then
  267.         materialslot=SucheBauMaterial()
  268.         if materialslot ~= false then
  269.             turtle.select(materialslot)
  270.             turtle.placeDown()
  271.         end
  272.     end
  273. end
  274.  
  275. ------------------------------------------------------
  276. term.clear()
  277. print("#-----------------------#")
  278. print("# STRIPMINING-PROGRAMM  #")
  279. print("# Einlegbare nuetzliche #")
  280. print("# Items sind: Eimer und #")
  281. print("# Fackeln... KEIN MUSS! #")
  282. print("#-----------------------#")
  283. print(" ")
  284.  
  285. term.write("Wieviele Gaenge? ")
  286. gaenge = tonumber(read())
  287. term.write("Wie weit? ")
  288. weite = tonumber(read())
  289. weite = weite
  290.  
  291. temp=false
  292. while temp == false do
  293.     term.write("Hoch-Runter-Fahren? (j/n) ")
  294.     hochrunter = read()
  295.     if hochrunter == "j" then
  296.         hochrunter = true
  297.         temp = true
  298.     end
  299.     if hochrunter == "n" then
  300.         hochrunter = false
  301.         temp = true
  302.     end
  303. end
  304.  
  305. richtung=false
  306. temp=false
  307. if gaenge>1 then
  308.     while temp == false do
  309.         term.write("Welche Richtung? (l/r) ")
  310.         richtung = read()
  311.         if richtung == "r" then
  312.             richtung = "rechts"
  313.             temp = true
  314.         end
  315.         if richtung == "l" then
  316.             richtung = "links"
  317.             temp = true
  318.         end
  319.     end
  320. end
  321.  
  322. SeheUndMache()
  323. itemzaehler=0
  324.  
  325. if turtle.detectUp() then
  326.     GrabeHoch()
  327.     itemzaehler=itemzaehler+1
  328. end
  329.  
  330. for i=1,gaenge do
  331.     for k=1,weite do
  332.         if turtle.detect() then
  333.             GrabeVor()
  334.             itemzaehler=itemzaehler+1
  335.         end
  336.         BaueBoden()
  337.         FahreVor()
  338.         if turtle.detectUp() then
  339.             GrabeHoch()
  340.             itemzaehler=itemzaehler+1
  341.         end
  342.        
  343.         if hochrunter == true then
  344.             FahreHoch()
  345.             FahreRunter()
  346.         end
  347.        
  348.         if itemzaehler>7 then
  349.             if IstInvVoll() == true then
  350.                 Aufraeumen()
  351.             end
  352.             itemzaehler=0
  353.         end
  354.         if k % 6 == 0 then
  355.             fackel=SucheItem("minecraft:torch")
  356.             if fackel ~= false then
  357.                 turtle.select(fackel)
  358.                 turtle.turnLeft()
  359.                 turtle.turnLeft()
  360.                 turtle.place()
  361.                 turtle.turnLeft()
  362.                 turtle.turnLeft()
  363.             end
  364.         end
  365.     end
  366.    
  367.     FahreHoch()
  368.     for k=1,weite do
  369.         FahreZurueck()
  370.     end
  371.     FahreRunter()
  372.    
  373.     if i<gaenge then
  374.         if richtung=="links" then
  375.             turtle.turnLeft()
  376.         else
  377.             turtle.turnRight()
  378.         end
  379.        
  380.         for e=1,3 do
  381.             GrabeHoch()
  382.             if hochrunter == true then
  383.                 FahreHoch()
  384.             end
  385.             GrabeVor()
  386.             FahreVor()
  387.             if hochrunter == true then
  388.                 GrabeRunter()
  389.                 FahreRunter()
  390.             else
  391.                 GrabeHoch()
  392.             end
  393.             BaueBoden()
  394.         end
  395.        
  396.         if richtung=="links" then
  397.             turtle.turnRight()
  398.         else
  399.             turtle.turnLeft()
  400.         end
  401.     end
  402. end
  403. if richtung=="links" then
  404.     turtle.turnLeft()
  405. else
  406.     turtle.turnRight()
  407. end
  408.  
  409. if gaenge>1 then
  410.     zufahren=gaenge-1
  411.     zufahren=zufahren*3
  412.     zufahren=zufahren-1
  413.     for i=0,zufahren do
  414.         FahreZurueck()
  415.         if i % 6 == 0 then
  416.             fackel=SucheItem("minecraft:torch")
  417.             if fackel ~= false then
  418.                 turtle.select(fackel)
  419.                 turtle.place()
  420.             end
  421.         end
  422.     end
  423. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement