Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rotation = true
- start = true
- done = false
- l = "Noch nicht definiert"
- lp = ""
- b = "Noch nicht definiert"
- bp = ""
- t = "Noch nicht definiert"
- tp = ""
- -- Bedienoberfläche --
- term.clear() term.setCursorPos(1,1)
- print("+-------------------------------------+")
- print("| Programm: Raumausheben 1.0 (1/2)|")
- print("| von xXNickBrickXx |")
- print("| |")
- print("| Programmzweck: |")
- print("| beliebig großen, quaderförmigen |")
- print("| Raum ausheben |")
- print("| Treibstoff: Slot 16 |")
- print("| Startpunkt (in Bezug auf Quader): |")
- print("| Links oben |")
- print("+-------------------------------------+")
- print("Press enter to continue:")
- while start do
- event, key = os.pullEvent("char")
- if key == "1" then
- start = false
- print("")
- print("+-------------------------------------+")
- print("| Maße des Raums (2/2)|")
- print("| |")
- print("| Länge: "..l.." |")
- print("| Breite: "..b.." |")
- print("| Tiefe: "..t.." |")
- print("+-------------------------------------+")
- print("")
- print(" Welche Länge soll dieser Raum haben?")
- print("")
- print("")
- print("")
- l = tonumber(read())
- if l == 10 then
- lp = "|"
- else
- if l < 10 then
- lp = " |"
- else
- lp = "|"
- end
- end
- print("")
- print("+-------------------------------------+")
- print("| Maße des Raums (2/2)|")
- print("| |")
- print("| Länge: "..l.." "..lp.."")
- print("| Breite: "..b.." |")
- print("| Tiefe: "..t.." |")
- print("+-------------------------------------+")
- print("")
- print(" Welche Breite soll dieser Raum haben?")
- print("")
- print("")
- print("")
- b = tonumber(read())
- if b == 10 then
- bp = "|"
- else
- if b < 10 then
- bp = " |"
- else
- bp = "|"
- end
- end
- print("")
- print("+-------------------------------------+")
- print("| Maße des Raums (2/2)|")
- print("| |")
- print("| Länge: "..l.." "..lp.."" )
- print("| Breite: "..b.." "..bp.."")
- print("| Tiefe: "..t.." |")
- print("+-------------------------------------+")
- print("")
- print(" Welche Tiefe soll dieser Raum haben?")
- print("")
- print("")
- print("")
- t = tonumber(read())
- if t == 10 then
- tp = "|"
- else
- if t < 10 then
- tp = " |"
- else
- tp = "|"
- end
- end
- local minFuelNeeded = l*b*t-1
- print("")
- print("+-------------------------------------+")
- print("| Maße des Raums (2/2)|")
- print("| |")
- print("| Länge: "..l.." "..lp.."")
- print("| Breite: "..b.." "..bp.."")
- print("| Tiefe: "..t.." "..tp.."")
- print("+-------------------------------------+")
- print("")
- print(" Es wurden alle Maße eingegeben!")
- print(" Es werden mindestens "..minFuelNeeded.." Treibstoff-")
- print(" einheiten benötigt!")
- print(" Starte in 5 Sekunden!")
- os.sleep(3)
- end
- end
- -- Basisfunctionen --
- local function gf(n)
- if n==nil then n=1 end
- for i = 1, n, 1 do
- while not turtle.forward() do end
- end
- end
- local function gb(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- while not turtle.back() do end
- end
- end
- local function gu(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- while not turtle.up() do end
- end
- end
- local function gd(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- while not turtle.down() do end
- end
- end
- local function gl(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- while not turtle.turnLeft() do end
- end
- end
- local function gr(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- while not turtle.turnRight() do end
- end
- end
- local function pf(n)
- if n==nil then n=1 end
- for i=1, n, 1 do
- if i~=1 then gb() end
- turtle.place()
- end
- end
- local function pu() turtle.placeUp() end
- local function pd() turtle.placeDown() end
- local function df() turtle.dig() end
- local function du() turtle.digUp() end
- local function dd() turtle.digDown() end
- local function sf() turtle.suck() end
- local function su() turtle.suckUp() end
- local function sd(n)
- if n==nil then
- while turtle.suckDown() do end
- else
- for i=1, n do
- turtle.suckDown()
- end
- end
- end
- local function Df() turtle.drop() end
- local function Du(n)
- if n==nil then n=64 end
- turtle.dropUp(n)
- end
- local function Dd(n)
- if n==nil then n=64 end
- turtle.dropDown(n)
- end
- local function ss(s) turtle.select(s) end
- -- Funktionen --
- function printClear()
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- end
- function checkFuel()
- local fuelLevel = turtle.getFuelLevel()
- local minFuelNeeded = l*b*t-1
- if fuelLevel < minFuelNeeded then
- ss(16)
- if turtle.getItemCount(16) == 0 then
- print("Ich brauche mehr Treibstoff für diesen Befehl!")
- os.sleep(5)
- printClear()
- checkFuel()
- else
- turtle.refuel(1)
- fuelLevel = turtle.getFuelLevel()
- if fuelLevel < minFuelNeeded then
- checkFuel()
- else
- print("Ich habe mich neu betankt und besitze nun genug Treibstoff für diesen Befehl!")
- end
- end
- else
- print("Ich besitze genug Treibstoff für diesen Befehl!")
- end
- ss(1)
- end
- function turn()
- if rotation then
- gr()
- else
- gl()
- end
- end
- function digUpSpace()
- for x=1, t, 1 do
- for y=1, b, 1 do
- for z=1, l-1, 1 do
- df() gf()
- end
- turn()
- if y~=b then
- df() gf()
- end
- turn()
- rotation = not rotation
- end
- if x~=t then
- dd() gd()
- end
- rotation = not rotation
- end
- end
- -- Hauptfunktion --
- printClear()
- checkFuel()
- digUpSpace()
- printClear()
- done = true
- print("+-------------------------------------+")
- print("| Programm: Raumausheben 1.0 |")
- print("| von xXNickBrickXx |")
- print("| |")
- print("| Raum fertig ausgehoben! |")
- print("| Vielen Dank, für die Wahl dieses |")
- print("| Programms! |")
- print("| |")
- print("| |")
- print("| |")
- print("+-------------------------------------+")
- print("Press enter to reboot:")
- while start do
- event, key = os.pullEvent("char")
- if key == "1" then
- start = false
- print("")
- print("+-------------------------------------+")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| BYE! |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("+-------------------------------------+")
- print("")
- os.sleep(4)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement