Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---By MarsGame
- local movesT = 0----Debug for Fuel Count
- ---User Variables
- local p = -1
- local pos = -1
- local a = -1
- local b = -1
- local c = -1
- ---System Variables
- local way = 0
- local maxFuel = turtle.getFuelLimit()
- if maxFuel == "unlimited" then maxFuel = -1 end
- local length = 0
- local length2 = 0
- local width = 0
- local width2 = 0
- local height = 0
- local totalFuelReq = 0
- ---Functions
- function printQuestions() ---Get Dimension and Pos of Turtle
- term.clear()
- term.setCursorPos(1,1)
- print("Wo ist die Turtle im Raum?")
- print("Oben Links: 1 Oben Rechts: 2")
- print("Unten Links: 3 Unten Rechts: 4")
- local pGO = 0
- while pGO == 0 do
- term.setCursorPos(1,4)
- term.clearLine()
- write("--) ")
- p = io.read()
- p = p + 0
- if p == 1 or p == 2 or p == 3 or p == 4 then
- pGO = 1
- end
- end
- pos = p
- print("Wie gross soll der Raum sein?")
- local aGo = 0
- while aGo == 0 do
- term.setCursorPos(1,6)
- term.clearLine()
- write("Laenge (Vorne)--) ")
- a = io.read()
- a = a - 1
- if a > 0 then
- aGo = 1
- end
- end
- length = a
- length2 = a
- local bGo = 0
- while bGo == 0 do
- term.setCursorPos(1,7)
- term.clearLine()
- write("Breite (Seite)--) ")
- b = io.read()
- b = b - 0
- if b > 0 then
- bGo = 1
- end
- end
- width = b
- local cGo = 0
- while cGo == 0 do
- term.setCursorPos(1,8)
- term.clearLine()
- write("Hoehe (Oben/Unten)--) ")
- c = io.read()
- c = c - 0
- if c > 0 then
- cGo = 1
- end
- end
- height = c
- way = turtle.getFuelLevel()
- end
- function printFuel() ---Print Fuel Screen
- term.setCursorPos(1,1)
- term.clear()
- turtle.select(1)
- if maxFuel ~= -1 then
- totalFuelReq = ((2 * a) * b * c) + (b * c) ---Every move needs 1 Fuel
- if totalFuelReq > way then
- print("Benoetigter Treibstoff: "..totalFuelReq)
- print("Die Turtle hat "..way.." Treibstoff")
- if totalFuelReq <= maxFuel then
- print("Du kannst fuer diesen Auftrag jetzt Auffuellen, damit er durchlaeuft.")
- print("Lege dazu Treibstoff in Slot 1 (Oben Links)")
- print("Treibstoff ist fast alles, was im Ofen benutzt werden kann.")
- print("Zum Tanken druecke '1'")
- print("Um jetzt zu starten '3', hier stoppt die Turtle wenn der Treibstoff zu ende geht!")
- else
- print("Dieser Raum ist zu gross um mit einmal Tanken alles zu schaffen!")
- print("Du kannst aber den Tank so voll machen wie es geht, damit die Turtle lange läuft.")
- print("Wenn sie Treibstoff braucht wartet sie bis sie welches bekommt.")
- print("Zum Tanken lege Treibstoff in Slot 1 (Oben Links)")
- print("Treibstoff ist fast alles, was im Ofen benutzt werden kann.")
- print("Zum Tanken druecke '1'")
- print("Um jetzt zu starten '3'")
- end
- local fuelStop = 0
- while fuelStop == 0 do
- local event,key = os.pullEvent("key")
- if key == keys.three then
- fuelStop = 1
- term.setCursorPos(1,10)
- print("Der Raum wird nun freigelegt.")
- sleep(2)
- elseif key == keys.one then
- turtle.refuel()
- term.setCursorPos(1,2)
- term.clearLine()
- print("Die Turtle hat "..way.." Treibstoff")
- end
- end
- else
- print("Die Turtle hat genut Treibstoff fuer diesen Auftrag.")
- sleep(2)
- end
- else
- print("In den Einstellungen wurde festgesetzt, dass Turtles keinen Treibstoff brauchen.")
- sleep(2)
- end
- end
- function ref() ---refuel, if Fuel gets Empty while running
- if maxFuel ~= -1 then
- way = turtle.getFuelLevel()
- local FuelErr = 0
- if way < 10 then
- turtle.select(1)
- while not turtle.refuel(1) do
- if FuelErr == 0 then
- FuelErr = 1
- print("In Slot 1 ist kein Treibstoff (Kohle etc.)")
- end
- sleep(2)
- end
- print("Treibstoff nachgetankt.")
- end
- end
- end
- function moveForward() ---Go forward/Mine if not possible
- ref()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- sleep(.25)
- end
- movesT = (movesT + 1) ---Debug
- end
- function go() ---Dig Room
- ---the height
- while height > 0 do
- height = (height - 1)
- ---the width
- while width > 0 do
- width = (width - 1)
- ---the length
- while length > 0 do
- length = (length - 1)
- moveForward()
- end
- turtle.turnRight()
- turtle.turnRight()
- ---the length back
- while length2 > 0 do
- moveForward()
- length2 = (length2 - 1)
- end
- length2 = a + 0
- length = a + 0
- ---turning for next line
- if not (width <= 0) then
- if pos == 1 or pos == 3 then
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- moveForward()
- turtle.turnRight()
- end
- width2 = (width2 + 1)
- end
- end
- width = b + 0
- if pos == 2 or pos == 4 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- while width2 > 0 do
- moveForward()
- width2 = (width2 - 1)
- end
- if not (height <= 0) then
- if pos == 3 or pos == 4 then
- while not turtle.up() do
- turtle.digUp()
- movesT = (movesT + 1) ---Debug
- end
- else
- while not turtle.down() do
- turtle.digDown()
- movesT = (movesT + 1) ---Debug
- end
- end
- end
- if pos == 1 or pos == 3 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- ---Start Programm
- printQuestions()
- printFuel()
- go()
- print("Fertig.")
- print("Fuel used:"..movesT)
- print("Fuel prediction:"..totalFuelReq)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement