Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Bauplatz einrichten
- -- Vorgabewerte erfragen
- term.clear()
- term.setCursorPos(1,1)
- print("Laenge des Bauplatzes [Blickrichtung Turtle]?")
- lang = io.read()
- print("Breite des Bauplatzes [Abstand nach links oder rechts]?")
- breit = io.read()
- print("Grabungsrichtung [l]inks oder [r]echts?")
- grabrichtung = io.read()
- print("Wie viele Ebenen hoch soll abgetragen werden[mind. 2,gerade Anzahl]?")
- ebenen = io.read()
- -- Werte anpassungen
- lang = lang - 1
- breit = breit - 1
- ebenen = ebenen + 0
- if ebenen <= 2 then
- ebenen = 2
- else
- if ebenen % 2 == 1 then
- ebenen = ebenen + 1
- end
- end
- -- Brennmaterialbedarf ermitteln und befüllen
- function fuelCheck()
- local fuelNeed = (lang+1) * (breit+1) * ebenen
- local currentFuel = turtle.getFuelLevel()
- if currentFuel < fuelNeed then
- print("Zu wenig Treibstoff. " .. currentFuel .. "/" .. fuelNeed)
- print("Bitte Slot angeben in dem der Treibstoff liegt:")
- local k = io.read()
- k = k + 0
- turtle.select(k)
- turtle.refuel()
- sleep(0.5)
- fuelCheck()
- else
- print("Treibstoffbedarf gedeckt: " .. currentFuel .. "/" .. fuelNeed)
- sleep(0.5)
- end
- end
- function moveForward()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- function turnEven()
- if grabrichtung == "l" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- function turnOdd()
- if grabrichtung == "r" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- function doPlain()
- for col = 0, breit, 1 do
- for row = 0, lang, 1 do
- moveForward()
- end
- if breit - col >= 1 then
- if col % 2 == 0 then
- turnEven()
- else
- turnOdd()
- end
- moveForward()
- if col % 2 == 0 then
- turnEven()
- else
- turnOdd()
- end
- end
- end
- end
- function moveDown()
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- end
- function switchDirection()
- if grabrichtung == "r" then
- grabrichtung = "l"
- else
- grabrichtung = "r"
- end
- end
- function turnAndDown()
- turtle.turnLeft()
- turtle.turnLeft()
- moveDown()
- end
- -- Testausgabe
- print(lang .. "x" .. breit .. "x" .. ebenen .. " Fuel: " .. turtle.getFuelLevel())
- fuelCheck()
- for i = 1, ebenen-1 do
- turtle.up()
- end
- moveForward()
- lang = lang - 1
- for i = 1, ebenen, 2 do
- print(lang .. "x" .. breit .. "x" .. ebenen .. " Fuel: " .. turtle.getFuelLevel())
- doPlain()
- turnAndDown()
- switchDirection()
- print(lang .. "x" .. breit .. "x" .. ebenen .. " Fuel: " .. turtle.getFuelLevel())
- doPlain()
- if ebenen-i > 1 then
- print("tad")
- turnAndDown()
- switchDirection()
- end
- end
- print(lang .. "x" .. breit .. "x" .. ebenen .. " Fuel: " .. turtle.getFuelLevel())
- moveForward()
- turtle.turnLeft()
- turtle.turnLeft()
Add Comment
Please, Sign In to add comment