CCCPaste

MC 1.12.2 Turtle Programm: Flächenbau (nicht...

local Version = 0.1
local Header = "---------------------------------------\n              Flächenbau V"..Version.."          \n---------------------------------------"
 
function clear()
    shell.run("clear")
    print(""..Header.."")
end
local drehen = "L"
local level = 0
local block = 0
local sel = 1
local wait = 0.5
--local hoch = 0
clear()
 
--======================================================================================================================================
 
function Beginn()
    --durchgaenge = hoch
	turtle.select(sel)
    drehungen = breit
    for b = 0, breit - 1 do
        Durchgang()
        drehungen = drehungen - 1
        if drehungen > 0 then
            Drehen()
        end
    end
    Zurueck()
    clear()
    --Steigen()
    --[[
    print("Soll ich weiter hoch?\nBin aktuell "..level.." ebenen hoch gegangen.")
    weiter2 = io.read()
    if weiter2 == "ja" then
        level = level + 1
        Steigen()
    end
    if weiter2 == "nein" then
        clear()
        print("Ok dann gehe ich auf ausgangsposition zurück\nund starte dann neu.")
        Senken()
        --sleep(2)
        --shell.run("clear")
    end
    ]]
end
 
function Senken()
    while level > 0 do
        turtle.down()
        level = level - 1
        print(""..level.."")
    end
end
 
function Steigen()
    print("level: "..level.."\nhoch: "..hoch.."")
    if hoch > 0 then
        level = level + 1
        hoch = hoch - 1
        print("level: "..level.."\nhoch: "..hoch.."")
    end
    --[[
    if hoch >= "0" then
        print("Steigen")
        while turtle.detectUp() do
            turtle.digUp()
            sleep(1)
        end
        turtle.up()
        hoch = hoch - 1
        level = level + 1
        Beginn()
    end
    if hoch >= 0 then
        print("Senken")
        Senken()
    end
    ]]
end
 
function Zurueck()
	while not turtle.detectDown() do
        turtle.placeDown()
		block = block+1
		blockCheck()
        sleep(wait)
    end
    if drehen == "R" then
        turtle.turnRight()
        for b = 1, breit - 1 do
            turtle.back()
        end
        turtle.turnRight()
    else
        for l = 1, lang - 1 do
            turtle.back()
        end
        turtle.turnLeft()
        for b = 1, breit - 1 do
            turtle.back()
        end
        turtle.turnRight()
    end
	shell.run("reboot")
    --frage()
end
 
function frage()
    print("Möchtest du das ich eine weitere ebene abbaue?\nJa oder Nein")
    oben = io.read()
    if oben == "ja" then
        while turtle.detectUp() do
            turtle.digUp()
            sleep(wait)
        end
        turtle.up()
        Beginn()
    else
        shell.run("reboot")
     end
end
 
function Durchgang()
    for l = 1, lang - 1 do
		while not turtle.detectDown() do
			turtle.placeDown()
			block = block+1
			blockCheck()
			sleep(wait)
		end
        --[[while turtle.detect() do
            turtle.dig()
            sleep(1)
        end]]
        turtle.forward()
    end
end
 
function Drehen()
    if drehen == "L" then
        turtle.turnLeft()
        while not turtle.detectDown() do
			turtle.placeDown()
			block = block+1
			blockCheck()
			sleep(wait)
		end
        turtle.forward()
        turtle.turnLeft()
        drehen = "R"
    else
        turtle.turnRight()
        while not turtle.detectDown() do
			turtle.placeDown()
			block = block+1
			blockCheck()
			sleep(wait)
		end
        turtle.forward()
        turtle.turnRight()
        drehen = "L"
    end
end

function blockCheck()
	if block == 64 then
		sel = sel+1
		turtle.select(sel)
		block = 0
	end
end

function placeDown()
	while not turtle.detectDown() do
        turtle.placeDown()
		block = block+1
		blockCheck()
        sleep(wait)
    end
end
--======================================================================================================================================
 
--print("Wie hoch soll der Bereich werden? (nicht verfügbar)")
local hoch = "1"
--clear()
print("Wie lang soll der Bereich werden?")
print("Bedenke maximale Fläche 32x32!\n")
lang = io.read()
clear()
print("Wie breit soll der Bereich werden?")
print("Bedenke maximale Fläche 32x32!\n")
breit = io.read()
clear()
print("Bedenke das ich in der unteren rechten Ecke des Raumes stehen muss um zu starten.\n")
print("Bedenke maximale Fläche 32x32!\n")
print("\nWenn ich dort stehe schreibe; ok")
weiter1 = io.read()
clear()
if weiter1 == "Ok" or "ok" or "OK" then
    Beginn()
end
 
--======================================================================================================================================