Advertisement
ecco7777

CC Miningscript by chatgpt

Apr 2nd, 2024
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | None | 0 0
  1. -- Funktion zum Zeichnen des UI
  2. local function drawUI()
  3.     term.clear()
  4.     term.setCursorPos(1,1)
  5.     print("Willkommen zum Strip Mine Schacht Programm")
  6.     print("Bitte gib die folgenden Informationen ein:")
  7.     print("")
  8.  
  9.     -- Benutzereingabe für die Höhe des Schachts
  10.     write("Höhe des Schachts: ")
  11.     local height = tonumber(read())
  12.  
  13.     -- Benutzereingabe für die Länge des Schachts
  14.     write("Länge des Schachts: ")
  15.     local length = tonumber(read())
  16.  
  17.     -- Benutzereingabe für die Anzahl der Schächte
  18.     write("Anzahl der Schächte: ")
  19.     local numMines = tonumber(read())
  20.  
  21.     -- Benutzereingabe für die Richtung der Schächte (links, rechts oder beides)
  22.     write("Richtung der Schächte (links/rechts/beides): ")
  23.     local direction = read()
  24.  
  25.     return height, length, numMines, direction
  26. end
  27.  
  28. -- Funktion zum Graben eines Schachts
  29. local function digMine(height, length, direction)
  30.     -- Schachtgraben
  31.     for i = 1, height do
  32.         for j = 1, length do
  33.             turtle.dig()
  34.             turtle.forward()
  35.         end
  36.         -- Richtungswechsel (falls beidseitig)
  37.         if direction == "beides" then
  38.             if i % 2 == 0 then
  39.                 turtle.turnRight()
  40.                 turtle.dig()
  41.                 turtle.forward()
  42.                 turtle.turnRight()
  43.             else
  44.                 turtle.turnLeft()
  45.                 turtle.dig()
  46.                 turtle.forward()
  47.                 turtle.turnLeft()
  48.             end
  49.         end
  50.         -- Zurück zur Ausgangsposition
  51.         if direction == "links" then
  52.             turtle.turnLeft()
  53.             for k = 1, length do
  54.                 turtle.forward()
  55.             end
  56.             turtle.turnRight()
  57.         elseif direction == "rechts" then
  58.             turtle.turnRight()
  59.             for k = 1, length do
  60.                 turtle.forward()
  61.             end
  62.             turtle.turnLeft()
  63.         end
  64.     end
  65. end
  66.  
  67. -- Hauptprogramm
  68. local function main()
  69.     local height, length, numMines, direction = drawUI()
  70.     print("Grabing Mines...")
  71.  
  72.     -- Schächte graben
  73.     for i = 1, numMines do
  74.         digMine(height, length, direction)
  75.         -- Zurück zur Ausgangsposition
  76.         if i < numMines then
  77.             turtle.turnLeft()
  78.             for j = 1, length do
  79.                 turtle.forward()
  80.             end
  81.             turtle.turnRight()
  82.         end
  83.     end
  84.  
  85.     print("Arbeit erledigt!")
  86. end
  87.  
  88. -- Hauptprogramm ausführen
  89. main()
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement