Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function compactInv()
- for checkSlot = 1, 16 do
- if turtle.getItemCount(checkSlot) > 0 then
- turtle.select(checkSlot)
- for testSlot = checkSlot, 16 do
- if turtle.compareTo(testSlot) then
- turtle.select(testSlot)
- turtle.transferTo(checkSlot, turtle.getItemCount(testSlot))
- turtle.select(checkSlot)
- end
- end
- end
- end
- end
- function cleanUp()
- for checkSlot = 16, 1, -1 do
- while turtle.getItemCount(checkSlot) > 0 do
- moveSlot = 16
- turtle.select(checkSlot)
- while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do
- moveSlot = moveSlot - 1
- end
- if moveSlot == checkSlot then
- break
- end
- end
- end
- end
- function sortInv()
- for checkSlot = 16, 1, -1 do
- if turtle.getItemCount(checkSlot) > 0 then
- turtle.select(checkSlot)
- moveSlot = 1
- while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do
- moveSlot = moveSlot + 1
- end
- turtle.select(moveSlot)
- for testSlot = 16, 1, -1 do
- moveSlot2 = moveSlot
- if testSlot > moveSlot2 then
- if turtle.getItemCount(testSlot) > 0 then
- if turtle.compareTo(testSlot) then
- turtle.select(testSlot)
- while not turtle.transferTo(moveSlot2, turtle.getItemCount(testSlot)) do
- moveSlot2 = moveSlot2 + 1
- end
- turtle.select(moveSlot)
- end
- end
- end
- end
- end
- end
- end
- function Aufraeumen()
- compactInv()
- cleanUp()
- sortInv()
- end
- function SucheItem(VollerItemname)
- for p=1,16 do
- if turtle.getItemCount(p) > 0 then
- turtle.select(p)
- data=turtle.getItemDetail()
- --print("data: ",data)
- --print("data.name: ",data.name)
- --print("VollerItemname: ",VollerItemname)
- --print("Slot: ", p)
- if data ~= false then
- if data.name == VollerItemname then
- --print("Hat geklappt")
- found=true
- slot=tonumber(p)
- return slot
- end
- if data.name == "minecraft:"..VollerItemname then
- --print("Hat geklappt")
- found=true
- slot=tonumber(p)
- return slot
- end
- end
- end
- end
- return false
- end
- function BlockVorTurtle()
- success, data = turtle.inspect()
- if success==true then
- --print("Block name: ", data.name)
- --print("Block metadata: ", data.metadata)
- return data.name
- else
- return false
- end
- end
- function BlockUnterTurtle()
- success, data = turtle.inspectDown()
- if success==true then
- --print("Block name: ", data.name)
- --print("Block metadata: ", data.metadata)
- return data.name
- else
- return false
- end
- end
- function BlockUeberTurtle()
- success, data = turtle.inspectUp()
- if success==true then
- --print("Block name: ", data.name)
- --print("Block metadata: ", data.metadata)
- return data.name
- else
- return false
- end
- end
- function SeheUndMache()
- vort=BlockVorTurtle()
- untert=BlockUnterTurtle()
- uebert=BlockUeberTurtle()
- if vort~= false then
- if vort == "minecraft:lava" then
- EntferneLava("Vor")
- end
- end
- if untert~= false then
- if untert == "minecraft:lava" then
- EntferneLava("Unten")
- end
- end
- if uebert~= false then
- if uebert == "minecraft:lava" then
- EntferneLava("Oben")
- end
- end
- end
- function FahreVor()
- SeheUndMache()
- while not turtle.forward() do
- sleep(1)
- end
- end
- function FahreZurueck()
- SeheUndMache()
- while not turtle.back() do
- sleep(1)
- end
- end
- function FahreHoch()
- SeheUndMache()
- while not turtle.up() do
- sleep(1)
- end
- end
- function FahreRunter()
- SeheUndMache()
- while not turtle.down() do
- sleep(1)
- end
- end
- function GrabeVor()
- while turtle.detect()==true do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- function GrabeRunter()
- turtle.digDown()
- end
- function GrabeHoch()
- while turtle.detectUp()==true do
- turtle.digUp()
- os.sleep(0.5)
- end
- end
- function SucheBauMaterial()
- matz={"dirt", "cobblestone", "limestone", "netherrack", "soulsand", "netherbrick"}
- for i=1, #matz do
- test=SucheItem(matz[i])
- if test ~= false then
- if test > 0 and test < 17 then
- return test
- end
- end
- end
- return false
- end
- function EntferneLava(wo)
- sleep(0.5)
- lavaeimer=SucheItem("lava_bucket")
- if lavaeimer ~= false then
- if lavaeimer > 0 and lavaeimer < 17 then
- turtle.select(lavaeimer)
- turtle.refuel()
- end
- end
- eimer=SucheItem("bucket")
- if eimer ~= false then
- if eimer > 0 and eimer < 17 then
- turtle.select(eimer)
- if wo == "Vor" then
- turtle.place()
- elseif wo == "Oben" then
- turtle.placeUp()
- elseif wo == "Unten" then
- turtle.placeDown()
- end
- sleep(0.5)
- lavaeimer=SucheItem("lava_bucket")
- if lavaeimer ~= false then
- if lavaeimer > 0 and lavaeimer < 17 then
- turtle.select(lavaeimer)
- turtle.refuel()
- end
- end
- end
- else
- materialslot=SucheBauMaterial()
- if materialslot ~= false then
- turtle.select(materialslot)
- if wo == "Vor" then
- turtle.place()
- GrabeVor()
- elseif wo == "Oben" then
- turtle.placeUp()
- GrabeHoch()
- elseif wo == "Unten" then
- turtle.placeDown()
- GrabeRunter()
- end
- end
- end
- end
- function RichtigDrehen(richtung, durchlauf)
- if durchlauf % 2 == 0 then
- if richtung == "links" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- else
- if richtung == "links" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- function IstInvVoll()
- for slot=1,16 do
- if turtle.getItemCount(slot)<1 then
- return false
- end
- end
- return true
- end
- ------------------------------------------------------
- term.clear()
- print("#-----------------------#")
- print("# LOCH-BUDDEL-PROGRAMM #")
- print("# Einlegbare nuetzliche #")
- print("# Items sind: Eimer und #")
- print("# Cobble... KEIN MUSS! #")
- print("#-----------------------#")
- print(" ")
- term.write("Wie breit? ")
- a = tonumber(read())
- breiteeingabe=a
- term.write("Wie weit? ")
- b = tonumber(read())
- weiteeingabe=b
- b = b-1
- term.write("Wie tief? ")
- c = tonumber(read())
- tiefeeingabe=c
- c=c+1
- richtung=false
- temp=false
- if a>1 then
- while temp == false do
- term.write("Welche Richtung? (l/r) ")
- richtung = read()
- if richtung == "l" then
- richtung = "rechts"
- temp = true
- end
- if richtung == "r" then
- richtung = "links"
- temp = true
- end
- end
- else
- richtung="links"
- end
- SeheUndMache()
- itemzaehler=0
- richtungsumkehrer=0
- for i=1,c do --c TIEFE
- if i>1 then
- --print("drehen 305")
- RichtigDrehen(richtung, a+richtungsumkehrer)
- GrabeRunter()
- FahreRunter()
- end
- if a % 2 == 0 and i>1 and i % 2 == 0 then
- richtungsumkehrer=1
- else
- richtungsumkehrer=0
- end
- --print("Tiefe i: ",i)
- for k=1,a do --a BREITE
- --print("Breite a: ",a)
- for m=1,b do --b WEITE
- --print("Weite b: ",b)
- if turtle.detect()==true then
- GrabeVor()
- itemzaehler=itemzaehler+1
- end
- FahreVor()
- if itemzaehler > 8 then
- if IstInvVoll() == true then
- Aufraeumen()
- end
- itemzaehler=0
- end
- end
- --print("drehen 323")
- RichtigDrehen(richtung, k+richtungsumkehrer)
- if k < a then
- if turtle.detect()==true then
- GrabeVor()
- itemzaehler=itemzaehler+1
- end
- FahreVor()
- if itemzaehler > 8 then
- if IstInvVoll() == true then
- Aufraeumen()
- end
- itemzaehler=0
- end
- --print("drehen 336")
- RichtigDrehen(richtung, k+richtungsumkehrer)
- end
- end
- end
- for i=1,c-1 do
- FahreHoch()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement