Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local breite = nil
- local hoehe = nil
- local tiefe = nil
- local x = nil -- Breite
- local y = nil -- Hoehe
- local z = nil -- Tiefe
- local richtung = nil
- local ou = nil
- local tSaveBlock ={}
- local gemined = 0
- local sz = 3
- -- Funktionen --
- local function ausgabe()
- local prozent = math.floor((gemined*100)/(breite*hoehe*tiefe))
- shell.run("clear")
- term.setTextColor(colors.white)
- print("Der Turtle arbeitet: ")
- term.setTextColor(colors.blue)
- print("Breite ", breite)
- term.setTextColor(colors.green)
- print("Hoehe ", hoehe)
- term.setTextColor(colors.yellow)
- print("Tiefe ", tiefe)
- if #tSaveBlock > 0 then
- term.setTextColor(colors.pink)
- print("Es werden folgende Bloecke gesichert:")
- for i, v in ipairs(tSaveBlock) do
- print(" "..i..". "..v)
- end
- end
- term.setTextColor(colors.red)
- if prozent >= 100 then
- print("Der Turtle ist fertig")
- else
- print("... "..prozent.."%")
- end
- end
- --
- local function oboun(obenunten)
- myApi.graben(obenunten)
- gemined = gemined + 1
- end
- local function obenuntenGerade()
- myApi.graben()
- myApi.graben("hoch")
- myApi.graben("runter")
- gemined = gemined + 3
- end
- local function untenGerade()
- myApi.graben()
- myApi.graben("runter")
- gemined = gemined + 2
- end
- local function obenGerade()
- myApi.graben()
- myApi.graben("hoch")
- gemined = gemined + 2
- end
- local function waagerechtGraben(obenunten, gerade)
- local abbauen = nil
- if gerade == nil and obenunten ~= nil then
- abbauen = oboun
- elseif obenunten == "hoch" and gerade == "gerade" then
- abbauen = obenGerade
- elseif obenunten == "runter" and gerade == "gerade" then
- abbauen = untenGerade
- else
- abbauen = obenuntenGerade
- end
- x = breite
- while x > 1 do
- abbauen(obenunten)
- if turtle.detect() then myApi.graben() end
- --[[ if myApi.saveBlock(tSaveBlock, 10) then
- turtle.idSelect("EnderStorage:enderChest")
- turtle.place()
- for i = 1, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.dig()
- end
- ]]--
- turtle.forward()
- x = x - 1
- ausgabe()
- end
- end
- ---
- local function senkrechtGraben(hochrunter)
- local schritte = 0
- local schritt = nil
- local abb = nil
- if hochrunter == "unten" then
- myApi.graben("hoch")
- schritt = turtle.down
- abb = "runter"
- elseif hochrunter == "oben" then
- myApi.graben("runter")
- schritt = turtle.up
- abb = "hoch"
- end
- gemined = gemined + 1
- while y > 2 and schritte < 3 do
- myApi.graben(abb)
- gemined = gemined + 1
- schritt()
- y = y - 1
- schritte = schritte + 1
- end
- turtle.turnRight()
- turtle.turnRight()
- return schritte
- end
- ---
- local function richtungsWechsel()
- if richtung == "links" then
- richtung = "rechts"
- elseif richtung == "rechts" then
- richtung = "links"
- end
- end
- --- Eingabe ---
- shell.run("clear")
- textutils.slowPrint("Bitte geben sie folgende Mase ein:\n", 15)
- local function eingabe(text)
- local mas = nil
- while true do
- local xPos, yPos = term.getCursorPos()
- term.write(text.."(>=3) ")
- mas = read()
- if tonumber(mas) ~= nil then
- if tonumber(mas) > 2 then
- break
- end
- end
- local tc = term.getTextColor()
- term.setTextColor(colors.red)
- print("Falsche Eingabe!")
- sleep(1)
- term.setCursorPos(xPos, yPos+1)
- term.clearLine()
- term.setTextColor(tc)
- term.setCursorPos(xPos, yPos)
- term.clearLine()
- end
- return mas
- end
- -----
- term.setTextColor(colors.blue)
- breite = eingabe("Breite") + 0
- term.setTextColor(colors.green)
- hoehe = eingabe("Hoehe") + 0
- term.setTextColor(colors.yellow)
- tiefe = eingabe("Tiefe") + 0
- term.setTextColor(colors.purple)
- local xPos, yPos = term.getCursorPos()
- while richtung ~= "rechts" and richtung ~= "links" do
- term.setCursorPos(xPos, yPos)
- term.clearLine()
- term.write("Startrichtung")
- term.setTextColor(colors.red)
- term.write("(rechts/links) ")
- term.setTextColor(colors.purple)
- richtung = read()
- end
- while ou ~= "oben" and ou ~= "unten" do
- term.setCursorPos(xPos, yPos + 1)
- term.clearLine()
- term.write("Startrichtung")
- term.setTextColor(colors.red)
- term.write("(oben/unten) ")
- term.setTextColor(colors.purple)
- ou = read()
- end
- term.setTextColor(colors.pink)
- print("Welche Bloeke sollen gesichert werden?: \n")
- for id in string.gmatch(read(),"[,]*%s*([:_%/%-%.%|%w+]+)") do
- table.insert(tSaveBlock, id)
- end
- --- START ---
- if ou == "oben" then
- myApi.graben("hoch")
- turtle.up()
- elseif ou == "unten" then
- myApi.graben("runter")
- turtle.down()
- end
- myApi.graben()
- gemined = gemined + 1
- turtle.forward()
- if richtung == "rechts" then
- turtle.turnRight()
- elseif richtung == "links" then
- turtle.turnLeft()
- end
- --- HAUPTPROGRAMM --
- local drehen = nil
- z = tiefe
- while z > 0 do
- y = hoehe - 1
- while y > 2 do
- waagerechtGraben()
- sz = senkrechtGraben(ou)
- ausgabe()
- richtungsWechsel()
- end
- if sz == 2 and ou == "unten" then
- waagerechtGraben("runter", "gerade")
- myApi.graben("runter")
- elseif sz == 2 and ou == "oben" then
- waagerechtGraben("hoch", "gerade")
- myApi.graben("hoch")
- elseif sz == 1 and ou == "unten" then
- waagerechtGraben("runter")
- myApi.graben("runter")
- elseif sz == 1 and ou == "oben" then
- waagerechtGraben("hoch")
- myApi.graben("hoch")
- else
- waagerechtGraben()
- myApi.graben("hoch")
- myApi.graben("runter")
- gemined = gemined + 1
- end
- gemined = gemined + 1
- if richtung == "links" then
- drehen = turtle.turnRight
- elseif richtung == "rechts" then
- drehen = turtle.turnLeft
- end
- richtungsWechsel()
- drehen()
- if z > 1 then
- myApi.graben()
- gemined = gemined + 1
- turtle.forward()
- end
- drehen()
- ausgabe()
- if ou == "unten" then
- ou = "oben"
- elseif ou == "oben" then
- ou = "unten"
- end
- z = z - 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement