Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Terraformingprogramm --
- -- von Thor_s_Crafter --
- -- Version 1.0 --
- t = turtle
- local currSlot = 1
- local currDir = 1
- local x = 0
- local y = 0
- local z = 0
- local counterX = 0
- local counterY = 0
- local counterZ = 0
- local function getNumber(text)
- local input
- while tonumber(input) == nil do
- term.clear()
- term.setCursorPos(1,1)
- write(text)
- input = read()
- if tonumber(input) == nil then
- print("Ungueltige Eingabe!")
- end
- end
- return tonumber(input)
- end
- local function getFuel()
- term.clear()
- while t.getFuelLevel() < x*y*z do
- term.setCursorPos(1,1)
- print("Bitte Kohle in Slot 1 legen!")
- print("Aktuelles FuelLevel: "..t.getFuelLevel().." ")
- print("Benoetigtes FuelLevel: "..x*y*z.." ")
- t.refuel()
- end
- end
- function userInput()
- term.clear()
- term.setCursorPos(1,1)
- print("Dieses Programm ebnet eine Flaeche!")
- print("Bitte dazu die Laenge,Breite und Hoehe")
- print("der zu ebnenden Flaeche eingeben!")
- print("Bitte Enter druecken...")
- read()
- x = getNumber("Laenge eingeben: ")
- y = getNumber("Breite eingeben: ")
- z = getNumber("Hoehe eingeben: ")
- getFuel()
- end
- function changeDir(dir)
- if dir == "-" then
- if currDir == 1 then
- currDir = 4
- else
- currDir = currDir - 1
- end
- elseif dir == "+" then
- if currDir == 4 then
- currDir = 1
- else
- currDir = currDir + 1
- end
- end
- end
- function getBack()
- while not currDir == 1 do
- t.turnLeft()
- changeDir("-")
- end
- for i=1, counterZ do
- t.down()
- end
- t.turnLeft()
- for i=1,counterY do
- t.back()
- end
- t.turnRight()
- for i=1,counterX do
- t.back()
- end
- t.turnLeft()
- t.turnLeft()
- end
- function dropAll()
- for i=1,16 do
- t.select(i)
- t.drop(64)
- end
- end
- function dropItems()
- local currDirTemp = currDir
- getBack()
- dropAll()
- t.turnLeft()
- t.turnLeft()
- for i=1,counterX do
- t.forward()
- end
- t.turnLeft()
- for i=1,counterY do
- t.forward()
- end
- t.turnRight()
- for i=1,counterZ do
- t.up()
- end
- while not currDir == currDirTemp do
- t.turnLeft()
- changeDir("-")
- end
- end
- function setSlot()
- while t.getItemCount() == 64 do
- if currSlot == 16 then
- dropItems()
- currSlot = 1
- else
- currSlot = currSlot + 1
- end
- t.select(currSlot)
- end
- end
- function digX(dir)
- for i=1,x do
- term.clear()
- term.setCursorPos(1,1)
- print("x: "..x)
- print("y: "..y)
- print("z: "..z)
- print()
- print("counterX: "..counterX)
- print("counterY: "..counterY)
- print("counterZ: "..counterZ)
- setSlot()
- t.dig()
- t.forward()
- if dir == "+" then
- counterX = counterX + 1
- elseif dir == "-" then
- counterX = counterX - 1
- end
- end
- t.dig()
- t.forward()
- end
- function digAll()
- term.clear()
- term.setCursorPos(1,1)
- local forY = 0
- if math.floor(tonumber(y/2))*2 then
- forY = math.floor(tonumber(y/2))+1
- y = math.floor(tonumber(y/2))+1
- else
- forY = tonumber(y/2)
- y = tonumber(y/2)
- end
- term.clear()
- for i=1,z do
- for i=1,forY do
- digX("+")
- t.turnLeft()
- changeDir("-")
- t.dig()
- t.forward()
- t.turnLeft()
- changeDir("-")
- counterY = counterY + 1
- digX("-")
- t.turnRight()
- changeDir("+")
- t.dig()
- t.forward()
- t.turnRight()
- changeDir("+")
- counterY = counterY + 1
- end
- getBack()
- t.turnLeft()
- t.turnLeft()
- counterX = 0
- counterY = 0
- counterZ = counterZ + 1
- for i=1,counterZ do
- t.up()
- end
- end
- for i=1,counterZ do
- t.down()
- end
- end
- userInput()
- digAll()
- term.clear()
- term.setCursorPos(1,1)
- print("Programm beendet!")
Advertisement
Add Comment
Please, Sign In to add comment