Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local aktSchacht = 1
- local aktLaenge = 0
- local zaehler = 0
- local status = ""
- function anzeige()
- shell.run("clear")
- print("Fuel: ", turtle.getFuelLevel())
- print("")
- print("Richtung: ", tArgs[3])
- print("Anzahl Schaechte:", tArgs[2])
- print("Aktueller Schacht:", aktSchacht)
- print("")
- print("Schachtgroesse: ", tArgs[1])
- print("Aktuelle Laenge: ", aktLaenge)
- print("")
- print("")
- print(status)
- end
- function testDig()
- turtle.dig()
- if turtle.detect()==true then
- testDig()
- end
- end
- function fackel()
- if zaehler>= 10 then
- turtle.turnLeft()
- testDig()
- turtle.forward()
- testDig()
- turtle.back()
- turtle.select(1)
- turtle.place()
- turtle.up()
- testDig()
- turtle.forward()
- testDig()
- turtle.back()
- turtle.down()
- turtle.turnRight()
- zaehler = 0
- end
- end
- function grabeSchacht()
- status = "Grabe Schacht..."
- turtle.turnRight()
- turtle.turnRight()
- testDig()
- turtle.up()
- testDig()
- turtle.select(1)
- turtle.place()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- for i=1, tArgs[1] do
- testDig()
- turtle.forward()
- turtle.digUp()
- aktLaenge = aktLaenge+1
- zaehler = zaehler+1
- anzeige()
- fackel()
- end
- shell.run("clear")
- status = "Rueckweg..."
- anzeige()
- for i=1, tArgs[1] do
- turtle.back()
- end
- shell.run("clear")
- end
- ------
- function durchsucheSchacht()
- status = "Suche nach Ressourcen..."
- turtle.forward()
- while not turtle.detect() do
- anzeige()
- successUnten, dataUnten = turtle.inspectDown()
- if assert(loadfile("istWertvoll"))(dataUnten["name"])==true then
- turtle.digDown()
- end
- turtle.turnLeft()
- successLinks, dataLinks = turtle.inspect()
- if assert(loadfile("istWertvoll"))(dataLinks["name"])==true then
- testDig()
- end
- turtle.turnRight()
- turtle.turnRight()
- successRechts, dataRechts = turtle.inspect()
- if assert(loadfile("istWertvoll"))(dataRechts["name"])==true then
- testDig()
- end
- turtle.turnLeft()
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- for i=1, tArgs[1] do
- successOben, dataOben = turtle.inspectUp()
- if assert(loadfile("istWertvoll"))(dataOben["name"])==true then
- turtle.digUp()
- end
- turtle.turnLeft()
- successObenLinks, dataObenLinks = turtle.inspect()
- if assert(loadfile("istWertvoll"))(dataObenLinks["name"])==true then
- testDig()
- end
- turtle.turnRight()
- turtle.turnRight()
- successObenRechts, dataObenRechts = turtle.inspect()
- if assert(loadfile("istWertvoll"))(dataObenRechts["name"])==true then
- testDig()
- end
- turtle.turnLeft()
- turtle.forward()
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function naechsterSchacht()
- zaehler = 0
- if tArgs[3] == "l" then
- turtle.turnLeft()
- for i=1,3 do
- testDig()
- turtle.forward()
- turtle.digUp()
- end
- turtle.turnRight()
- elseif tArgs[3] == "r" then
- turtle.turnRight()
- for i=1, 3 do
- testDig()
- turtle.forward()
- turtle.digUp()
- end
- turtle.turnLeft()
- else
- print("Fehlerhafte Richtung!")
- end
- end
- function start()
- local anzSchaechte = tonumber(tArgs[2])
- local schachtVerbrauch = (tonumber(tArgs[1])*4) + (tonumber(tArgs[1])/5) + 2
- print("Fuel aktuell: ", turtle.getFuelLevel())
- print("Voraussichtlicher Verbrauch: ", anzSchaechte*schachtVerbrauch, "(", schachtVerbrauch," pro Schacht)")
- print("")
- print("Auffuellen, Starten oder Abbrechen?")
- print("('auffuellen', 'start', 'abbruch')")
- local aufforderung = read()
- if aufforderung ~= "auffuellen" and aufforderung ~= "start" and aufforderung ~= "abbruch" then
- print("Falsche Eingabe! Programm abgebrochen.")
- return
- end
- if aufforderung == "auffuellen" then
- turtle.refuel()
- elseif aufforderung == "start" then
- if turtle.getFuelLevel() < schachtVerbrauch then
- print("WARNUNG! Voraussichtlicher Verbrauch höher als Fuel!")
- print("Soll Schacht trotzdem gebaut werden?")
- print("('yes', 'no')")
- local tdmBauen = read()
- if tdmBauen ~= "yes" and tdmBauen ~= "no" then
- print("Falsche Eingabe! Programm abgebrochen.")
- return
- end
- if tdmBauen == "no" then
- shell.run("clear")
- start()
- end
- end
- elseif aufforderung == abbruch then
- print("Programm abgebrochen!")
- return
- end
- end
- ------
- --HAUPTPROGRAMM--
- local anzSchaechte = tonumber(tArgs[2])
- local schachtVerbrauch = (tonumber(tArgs[1])*4) + (tonumber(tArgs[1])/5) + 2
- if tArgs[3] ~= "r" and tArgs[3] ~= "l" then
- print("Ungueltige Richtung (Nur l oder r)!")
- return
- end
- start()
- if anzSchaechte == 1 then
- grabeSchacht()
- durchsucheSchacht()
- elseif anzSchaechte > 1 then
- for i=1, anzSchaechte-1 do
- aktSchacht = i
- grabeSchacht()
- durchsucheSchacht()
- naechsterSchacht()
- end
- grabeSchacht()
- durchsucheSchacht()
- else
- print("Ungueltige Schachtanzahl!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement