Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Funktion zum Zeichnen des UI
- local function drawUI()
- term.clear()
- term.setCursorPos(1,1)
- print("Willkommen zum Strip Mine Schacht Programm")
- print("Bitte gib die folgenden Informationen ein:")
- print("")
- -- Benutzereingabe für die Höhe des Schachts
- write("Höhe des Schachts: ")
- local height = tonumber(read())
- -- Benutzereingabe für die Länge des Schachts
- write("Länge des Schachts: ")
- local length = tonumber(read())
- -- Benutzereingabe für die Anzahl der Schächte
- write("Anzahl der Schächte: ")
- local numMines = tonumber(read())
- -- Benutzereingabe für die Richtung der Schächte (links, rechts oder beides)
- write("Richtung der Schächte (links/rechts/beides): ")
- local direction = read()
- return height, length, numMines, direction
- end
- -- Funktion zum Graben eines Schachts
- local function digMine(height, length, direction)
- -- Schachtgraben
- for i = 1, height do
- for j = 1, length do
- turtle.dig()
- turtle.forward()
- end
- -- Richtungswechsel (falls beidseitig)
- if direction == "beides" then
- if i % 2 == 0 then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- -- Zurück zur Ausgangsposition
- if direction == "links" then
- turtle.turnLeft()
- for k = 1, length do
- turtle.forward()
- end
- turtle.turnRight()
- elseif direction == "rechts" then
- turtle.turnRight()
- for k = 1, length do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- end
- end
- -- Hauptprogramm
- local function main()
- local height, length, numMines, direction = drawUI()
- print("Grabing Mines...")
- -- Schächte graben
- for i = 1, numMines do
- digMine(height, length, direction)
- -- Zurück zur Ausgangsposition
- if i < numMines then
- turtle.turnLeft()
- for j = 1, length do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- print("Arbeit erledigt!")
- end
- -- Hauptprogramm ausführen
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement