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 IstInvVoll()
- for slot=1,16 do
- if turtle.getItemCount(slot)<1 then
- return false
- end
- end
- return true
- 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 BaueBoden()
- if not turtle.detectDown() then
- materialslot=SucheBauMaterial()
- if materialslot ~= false then
- turtle.select(materialslot)
- turtle.placeDown()
- end
- end
- end
- ------------------------------------------------------
- term.clear()
- print("#-----------------------#")
- print("# STRIPMINING-PROGRAMM #")
- print("# Einlegbare nuetzliche #")
- print("# Items sind: Eimer und #")
- print("# Fackeln... KEIN MUSS! #")
- print("#-----------------------#")
- print(" ")
- term.write("Wieviele Gaenge? ")
- gaenge = tonumber(read())
- term.write("Wie weit? ")
- weite = tonumber(read())
- weite = weite
- temp=false
- while temp == false do
- term.write("Hoch-Runter-Fahren? (j/n) ")
- hochrunter = read()
- if hochrunter == "j" then
- hochrunter = true
- temp = true
- end
- if hochrunter == "n" then
- hochrunter = false
- temp = true
- end
- end
- richtung=false
- temp=false
- if gaenge>1 then
- while temp == false do
- term.write("Welche Richtung? (l/r) ")
- richtung = read()
- if richtung == "r" then
- richtung = "rechts"
- temp = true
- end
- if richtung == "l" then
- richtung = "links"
- temp = true
- end
- end
- end
- SeheUndMache()
- itemzaehler=0
- if turtle.detectUp() then
- GrabeHoch()
- itemzaehler=itemzaehler+1
- end
- for i=1,gaenge do
- for k=1,weite do
- if turtle.detect() then
- GrabeVor()
- itemzaehler=itemzaehler+1
- end
- BaueBoden()
- FahreVor()
- if turtle.detectUp() then
- GrabeHoch()
- itemzaehler=itemzaehler+1
- end
- if hochrunter == true then
- FahreHoch()
- FahreRunter()
- end
- if itemzaehler>7 then
- if IstInvVoll() == true then
- Aufraeumen()
- end
- itemzaehler=0
- end
- if k % 6 == 0 then
- fackel=SucheItem("minecraft:torch")
- if fackel ~= false then
- turtle.select(fackel)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- end
- FahreHoch()
- for k=1,weite do
- FahreZurueck()
- end
- FahreRunter()
- if i<gaenge then
- if richtung=="links" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for e=1,3 do
- GrabeHoch()
- if hochrunter == true then
- FahreHoch()
- end
- GrabeVor()
- FahreVor()
- if hochrunter == true then
- GrabeRunter()
- FahreRunter()
- else
- GrabeHoch()
- end
- BaueBoden()
- end
- if richtung=="links" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- if richtung=="links" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if gaenge>1 then
- zufahren=gaenge-1
- zufahren=zufahren*3
- zufahren=zufahren-1
- for i=0,zufahren do
- FahreZurueck()
- if i % 6 == 0 then
- fackel=SucheItem("minecraft:torch")
- if fackel ~= false then
- turtle.select(fackel)
- turtle.place()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement