Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- perfect_miner_fast.lua
- -- CC:Tweaked / ComputerCraft Mining Turtle
- -- Optimierte Version
- --
- -- SLOTPLAN:
- -- Slot 1 = Bau-/Auffuellmaterial, z.B. Cobblestone
- -- Slot 2 = Fuel
- -- Slot 3-16 = gesammelte Items
- --
- -- AUFSTELLUNG:
- -- [ KISTE ] [ TURTLE ] ---> Mining-Richtung
- --
- -- Die Turtle schaut beim Start nach vorne in den Mining-Bereich.
- -- Die Kiste steht direkt hinter der Turtle.
- local BUILD_SLOT = 1
- local FUEL_SLOT = 2
- local ITEM_FIRST = 3
- local ITEM_LAST = 16
- -- Position relativ zum Start
- -- x = vorne
- -- y = rechts positiv / links negativ
- -- z = unten positiv
- local x, y, z = 0, 0, 0
- -- Richtung: 0 vorne, 1 rechts, 2 hinten, 3 links
- local dir = 0
- local mode = ""
- local length = 0
- local width = 0
- local depth = 0
- local height = 0
- local sideSign = 1
- local blocksTarget = 0
- local blocksDone = 0
- local unloads = 0
- local trashDropped = 0
- local bedrockHit = false
- local startClock = os.clock()
- local isReturning = false
- local cfg = {
- filterMode = "blacklist", -- all, blacklist, whitelist
- throwTrashDown = true,
- stackItems = true,
- lowFuelReturn = true,
- reserveFuel = 200,
- bridgeMode = false,
- fluidMode = "stop", -- stop, seal, ignore
- bedrockStop = true,
- progressEvery = 50,
- maintenanceEvery = 10,
- }
- local TRASH_ITEMS = {}
- local KEEP_ITEMS = {}
- -- =========================================================
- -- UI
- -- =========================================================
- local function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function pause(msg)
- if msg then print(msg) end
- print("Enter druecken...")
- read()
- end
- local function yn(text, default)
- while true do
- if default == true then
- write(text .. " (J/n): ")
- elseif default == false then
- write(text .. " (j/N): ")
- else
- write(text .. " (j/n): ")
- end
- local a = string.lower(read())
- if a == "" and default ~= nil then return default end
- if a == "j" or a == "ja" or a == "y" or a == "yes" then return true end
- if a == "n" or a == "nein" or a == "no" then return false end
- print("Bitte j oder n eingeben.")
- end
- end
- local function askNumber(text, min, default)
- min = min or 1
- while true do
- if default then
- write(text .. " [" .. default .. "]: ")
- else
- write(text .. ": ")
- end
- local input = read()
- if input == "" and default then
- return default
- end
- local n = tonumber(input)
- if n and n >= min and math.floor(n) == n then
- return n
- end
- print("Bitte eine ganze Zahl >= " .. min .. " eingeben.")
- end
- end
- local function askChoice(text, choices, default)
- while true do
- print(text)
- for i, c in ipairs(choices) do
- print(i .. " = " .. c.label)
- end
- if default then
- write("Auswahl [" .. default .. "]: ")
- else
- write("Auswahl: ")
- end
- local input = read()
- if input == "" and default then
- return choices[default].value
- end
- local n = tonumber(input)
- if n and choices[n] then
- return choices[n].value
- end
- print("Ungueltige Auswahl.")
- end
- end
- local function drawSlotPlan()
- clear()
- print("=== PERFECT MINER FAST ===")
- print("")
- print("Aufstellung:")
- print("")
- print(" [ KISTE ] [ TURTLE ] ---> Mining-Richtung")
- print(" vorne")
- print("")
- print("Die Turtle muss nach vorne in den Mining-Bereich schauen.")
- print("Die Kiste muss direkt HINTER der Turtle stehen.")
- print("")
- print("Inventar:")
- print("+------+------+------+------+")
- print("| 1 | 2 | 3 | 4 |")
- print("|Block | Fuel | Item | Item |")
- print("+------+------+------+------+")
- print("| 5 | 6 | 7 | 8 |")
- print("| Item | Item | Item | Item |")
- print("+------+------+------+------+")
- print("| 9 | 10 | 11 | 12 |")
- print("| Item | Item | Item | Item |")
- print("+------+------+------+------+")
- print("| 13 | 14 | 15 | 16 |")
- print("| Item | Item | Item | Item |")
- print("+------+------+------+------+")
- print("")
- print("Slot 1: Bau-/Auffuellmaterial")
- print("Slot 2: Fuel")
- print("Slots 3-16: Sammel-Items")
- print("")
- print("Slot 1 und 2 werden nie in die Kiste entleert.")
- print("")
- pause()
- end
- -- =========================================================
- -- ITEM-LISTEN
- -- =========================================================
- local function add(t, name)
- t[name] = true
- end
- local function setupDefaultLists()
- TRASH_ITEMS = {
- ["minecraft:cobblestone"] = true,
- ["minecraft:cobbled_deepslate"] = true,
- ["minecraft:gravel"] = true,
- ["minecraft:sand"] = true,
- ["minecraft:dirt"] = true,
- ["minecraft:flint"] = true,
- }
- KEEP_ITEMS = {
- ["minecraft:coal"] = true,
- ["minecraft:charcoal"] = true,
- ["minecraft:raw_iron"] = true,
- ["minecraft:raw_gold"] = true,
- ["minecraft:raw_copper"] = true,
- ["minecraft:iron_ingot"] = true,
- ["minecraft:gold_ingot"] = true,
- ["minecraft:copper_ingot"] = true,
- ["minecraft:iron_nugget"] = true,
- ["minecraft:gold_nugget"] = true,
- ["minecraft:redstone"] = true,
- ["minecraft:lapis_lazuli"] = true,
- ["minecraft:diamond"] = true,
- ["minecraft:emerald"] = true,
- ["minecraft:iron_ore"] = true,
- ["minecraft:deepslate_iron_ore"] = true,
- ["minecraft:gold_ore"] = true,
- ["minecraft:deepslate_gold_ore"] = true,
- ["minecraft:copper_ore"] = true,
- ["minecraft:deepslate_copper_ore"] = true,
- ["minecraft:coal_ore"] = true,
- ["minecraft:deepslate_coal_ore"] = true,
- ["minecraft:redstone_ore"] = true,
- ["minecraft:deepslate_redstone_ore"] = true,
- ["minecraft:lapis_ore"] = true,
- ["minecraft:deepslate_lapis_ore"] = true,
- ["minecraft:diamond_ore"] = true,
- ["minecraft:deepslate_diamond_ore"] = true,
- ["minecraft:emerald_ore"] = true,
- ["minecraft:deepslate_emerald_ore"] = true,
- ["minecraft:ancient_debris"] = true,
- ["minecraft:nether_quartz_ore"] = true,
- ["minecraft:quartz"] = true,
- ["minecraft:andesite"] = true,
- ["minecraft:tuff"] = true,
- }
- end
- -- =========================================================
- -- FUEL
- -- =========================================================
- local function fuel()
- return turtle.getFuelLevel()
- end
- local function fuelUnlimited()
- return fuel() == "unlimited"
- end
- local function refuelOne()
- if fuelUnlimited() then return true end
- local old = turtle.getSelectedSlot()
- turtle.select(FUEL_SLOT)
- if turtle.getItemCount(FUEL_SLOT) <= 0 then
- turtle.select(old)
- return false
- end
- local ok = turtle.refuel(1)
- turtle.select(old)
- return ok
- end
- local function topUpFuel()
- if fuelUnlimited() then return true end
- while fuel() < cfg.reserveFuel and turtle.getItemCount(FUEL_SLOT) > 1 do
- if not refuelOne() then break end
- end
- return fuel() > 2
- end
- local function ensureFuelBasic()
- if fuelUnlimited() then return true end
- while fuel() <= 2 do
- if not refuelOne() then
- print("")
- print("Fuel ist zu niedrig.")
- print("Lege Fuel in Slot 2 und druecke Enter.")
- read()
- end
- end
- return true
- end
- local function estimateHomeDistance()
- return math.abs(x) + math.abs(y) + math.abs(z) + 8
- end
- -- =========================================================
- -- INVENTAR
- -- =========================================================
- local function shouldTrash(name)
- if not name then return false end
- if cfg.filterMode == "all" then
- return false
- elseif cfg.filterMode == "blacklist" then
- return TRASH_ITEMS[name] == true
- elseif cfg.filterMode == "whitelist" then
- return KEEP_ITEMS[name] ~= true
- end
- return false
- end
- local function throwTrash()
- local old = turtle.getSelectedSlot()
- for i = ITEM_FIRST, ITEM_LAST do
- local d = turtle.getItemDetail(i)
- if d and shouldTrash(d.name) then
- turtle.select(i)
- if cfg.throwTrashDown then
- turtle.dropDown()
- else
- turtle.drop()
- end
- trashDropped = trashDropped + d.count
- end
- end
- turtle.select(old)
- end
- local function stackItems()
- if not cfg.stackItems then return end
- for source = ITEM_FIRST, ITEM_LAST do
- if turtle.getItemCount(source) > 0 then
- turtle.select(source)
- for target = ITEM_FIRST, ITEM_LAST do
- if source ~= target and turtle.getItemCount(target) > 0 then
- if turtle.compareTo(target) then
- turtle.transferTo(target)
- end
- end
- end
- end
- end
- turtle.select(ITEM_FIRST)
- end
- local function inventoryAlmostFull()
- local empty = 0
- local space = 0
- for i = ITEM_FIRST, ITEM_LAST do
- if turtle.getItemCount(i) == 0 then empty = empty + 1 end
- space = space + turtle.getItemSpace(i)
- end
- return empty <= 1 or space < 64
- end
- -- =========================================================
- -- DREHEN
- -- =========================================================
- local function turnLeft()
- turtle.turnLeft()
- dir = (dir + 3) % 4
- end
- local function turnRight()
- turtle.turnRight()
- dir = (dir + 1) % 4
- end
- local function turnTo(target)
- if dir == target then return end
- local diff = (target - dir) % 4
- if diff == 1 then
- turnRight()
- elseif diff == 3 then
- turnLeft()
- elseif diff == 2 then
- turnRight()
- turnRight()
- end
- end
- local function updateForwardPos()
- if dir == 0 then
- x = x + 1
- elseif dir == 1 then
- y = y + 1
- elseif dir == 2 then
- x = x - 1
- elseif dir == 3 then
- y = y - 1
- end
- end
- -- =========================================================
- -- FLUESSIGKEITEN / BAUEN
- -- =========================================================
- local function isFluidName(name)
- return name == "minecraft:water"
- or name == "minecraft:lava"
- or name == "minecraft:flowing_water"
- or name == "minecraft:flowing_lava"
- end
- local function hasBuildBlock()
- return turtle.getItemCount(BUILD_SLOT) > 0
- end
- local function placeBuildForward()
- if not hasBuildBlock() then return false end
- local old = turtle.getSelectedSlot()
- turtle.select(BUILD_SLOT)
- local ok = turtle.place()
- turtle.select(old)
- return ok
- end
- local function placeBuildDown()
- if not hasBuildBlock() then return false end
- local old = turtle.getSelectedSlot()
- turtle.select(BUILD_SLOT)
- local ok = turtle.placeDown()
- turtle.select(old)
- return ok
- end
- local function handleFluidForward()
- if cfg.fluidMode == "ignore" then return true end
- local ok, data = turtle.inspect()
- if ok and data and data.name and isFluidName(data.name) then
- print("")
- print("Fluessigkeit vor der Turtle: " .. data.name)
- if cfg.fluidMode == "seal" then
- if placeBuildForward() then
- sleep(0.1)
- return true
- end
- print("Keine Bau-/Auffuellbloecke in Slot 1.")
- end
- print("Bitte sichern und Enter druecken.")
- read()
- end
- return true
- end
- local function handleFluidDown()
- if cfg.fluidMode == "ignore" then return true end
- local ok, data = turtle.inspectDown()
- if ok and data and data.name and isFluidName(data.name) then
- print("")
- print("Fluessigkeit unter der Turtle: " .. data.name)
- if cfg.fluidMode == "seal" then
- if placeBuildDown() then
- sleep(0.1)
- return true
- end
- print("Keine Bau-/Auffuellbloecke in Slot 1.")
- end
- print("Bitte sichern und Enter druecken.")
- read()
- end
- return true
- end
- local function bridgeIfNeeded()
- -- Wichtig:
- -- Es wird NUR gesetzt, wenn Brueckenmodus aktiv ist UND unter der Turtle wirklich Luft ist.
- -- Bereits ausgehobene Bloecke werden nicht wieder aufgefuellt.
- if cfg.bridgeMode and not turtle.detectDown() then
- placeBuildDown()
- end
- end
- -- =========================================================
- -- GRABEN / BEWEGEN
- -- =========================================================
- local function safeDigForward()
- handleFluidForward()
- local loops = 0
- while turtle.detect() do
- if cfg.bedrockStop then
- local ok, data = turtle.inspect()
- if ok and data and data.name == "minecraft:bedrock" then
- bedrockHit = true
- return false
- end
- end
- turtle.dig()
- loops = loops + 1
- -- Nur bei nachfallendem Sand/Gravel mehrfach versuchen.
- if loops > 30 then break end
- sleep(0.05)
- end
- return true
- end
- local function safeDigUp()
- local loops = 0
- while turtle.detectUp() do
- turtle.digUp()
- loops = loops + 1
- if loops > 30 then break end
- sleep(0.05)
- end
- return true
- end
- local function safeDigDown()
- handleFluidDown()
- local loops = 0
- while turtle.detectDown() do
- if cfg.bedrockStop then
- local ok, data = turtle.inspectDown()
- if ok and data and data.name == "minecraft:bedrock" then
- bedrockHit = true
- return false
- end
- end
- turtle.digDown()
- loops = loops + 1
- if loops > 30 then break end
- sleep(0.05)
- end
- return true
- end
- local function forwardRaw()
- ensureFuelBasic()
- if not safeDigForward() then
- return false
- end
- while not turtle.forward() do
- turtle.attack()
- if not safeDigForward() then
- return false
- end
- sleep(0.05)
- end
- updateForwardPos()
- bridgeIfNeeded()
- return true
- end
- local function upRaw()
- ensureFuelBasic()
- safeDigUp()
- while not turtle.up() do
- turtle.attackUp()
- safeDigUp()
- sleep(0.05)
- end
- z = z - 1
- return true
- end
- local function downRaw()
- ensureFuelBasic()
- if not safeDigDown() then
- return false
- end
- while not turtle.down() do
- turtle.attackDown()
- if not safeDigDown() then
- return false
- end
- sleep(0.05)
- end
- z = z + 1
- bridgeIfNeeded()
- return true
- end
- local function moveX(tx)
- while x < tx do
- turnTo(0)
- if not forwardRaw() then return false end
- end
- while x > tx do
- turnTo(2)
- if not forwardRaw() then return false end
- end
- return true
- end
- local function moveY(ty)
- while y < ty do
- turnTo(1)
- if not forwardRaw() then return false end
- end
- while y > ty do
- turnTo(3)
- if not forwardRaw() then return false end
- end
- return true
- end
- local function moveZ(tz)
- while z < tz do
- if not downRaw() then return false end
- end
- while z > tz do
- if not upRaw() then return false end
- end
- return true
- end
- local function goTo(tx, ty, tz)
- -- Reihenfolge ist bewusst so:
- -- Erst vertikal, dann horizontal.
- -- In den meisten Modi bewegt sich die Turtle dadurch durch bereits freigelegte Luft.
- if not moveZ(tz) then return false end
- if not moveX(tx) then return false end
- if not moveY(ty) then return false end
- return true
- end
- -- =========================================================
- -- WARTUNG / KISTE
- -- =========================================================
- local function dropIntoChest()
- turnTo(2)
- for i = ITEM_FIRST, ITEM_LAST do
- turtle.select(i)
- while turtle.getItemCount(i) > 0 do
- local ok = turtle.drop()
- if not ok then
- print("")
- print("Kiste voll oder nicht erreichbar.")
- print("Bitte Kiste leeren/pruefen und Enter druecken.")
- read()
- end
- end
- end
- turtle.select(ITEM_FIRST)
- unloads = unloads + 1
- end
- local function goHomeAndUnload()
- if isReturning then return end
- isReturning = true
- local sx, sy, sz, sd = x, y, z, dir
- print("")
- print("Fahre zur Kiste...")
- goTo(0, 0, 0)
- dropIntoChest()
- print("Fahre zurueck...")
- goTo(sx, sy, sz)
- turnTo(sd)
- isReturning = false
- end
- local function showProgress(force)
- if not force and blocksDone % cfg.progressEvery ~= 0 then
- return
- end
- local elapsed = os.clock() - startClock
- local percent = 0
- local eta = "?"
- if blocksTarget > 0 then
- percent = math.floor((blocksDone / blocksTarget) * 100)
- end
- if blocksDone > 0 then
- local perBlock = elapsed / blocksDone
- local remaining = math.max(0, blocksTarget - blocksDone)
- local seconds = math.floor(perBlock * remaining)
- eta = math.floor(seconds / 60) .. "m " .. (seconds % 60) .. "s"
- end
- print(
- "Fortschritt " .. percent .. "% | " ..
- blocksDone .. "/" .. blocksTarget .. " | " ..
- "Fuel " .. tostring(fuel()) .. " | " ..
- "Entladungen " .. unloads .. " | " ..
- "ETA " .. eta
- )
- end
- local function maintenance(force)
- if isReturning then return end
- if not force and blocksDone % cfg.maintenanceEvery ~= 0 then
- return
- end
- throwTrash()
- stackItems()
- if cfg.lowFuelReturn and not fuelUnlimited() then
- topUpFuel()
- if fuel() < estimateHomeDistance() + 5 then
- print("Fuel niedrig. Kehre zur Kiste zurueck.")
- goHomeAndUnload()
- end
- end
- if inventoryAlmostFull() then
- goHomeAndUnload()
- end
- end
- local function markBlock()
- blocksDone = blocksDone + 1
- maintenance(false)
- showProgress(false)
- end
- local function visit(tx, ty, tz)
- if bedrockHit then return false end
- if not goTo(tx, ty, tz) then
- return false
- end
- markBlock()
- return true
- end
- -- =========================================================
- -- OPTIMIERTE MINING-PFADE
- -- =========================================================
- local function visitPlaneOptimized(tx, yMin, yMax, zMin, zMax, reverseY)
- -- Optimierte Flaeche bei festem x.
- -- Die Turtle laeuft in einer Schlange, damit sie nicht staendig zurueckfaehrt.
- local yStart, yEnd, yStep
- if reverseY then
- yStart = yMax
- yEnd = yMin
- yStep = -1
- else
- yStart = yMin
- yEnd = yMax
- yStep = 1
- end
- local row = 0
- local ty = yStart
- while true do
- local reverseZ = (row % 2 == 1)
- if reverseZ then
- for tz = zMax, zMin, -1 do
- if not visit(tx, ty, tz) then return false end
- end
- else
- for tz = zMin, zMax do
- if not visit(tx, ty, tz) then return false end
- end
- end
- if ty == yEnd then break end
- ty = ty + yStep
- row = row + 1
- end
- return true
- end
- local function mineTunnel1x2(len)
- blocksTarget = len * 2
- for tx = 1, len do
- if bedrockHit then break end
- if tx % 2 == 1 then
- visit(tx, 0, 0)
- visit(tx, 0, -1)
- else
- visit(tx, 0, -1)
- visit(tx, 0, 0)
- end
- end
- end
- local function mineTunnel(size, len)
- -- 3x3 oder 5x5 Tunnel.
- -- Pro x-Ebene wird eine Schlangenflaeche abgefahren.
- -- Zwischen Ebenen bleibt die Turtle am letzten Punkt und geht direkt in die naechste Ebene.
- local radius = math.floor(size / 2)
- local yMin = -radius
- local yMax = radius
- local zMin = -(size - 1)
- local zMax = 0
- blocksTarget = len * size * size
- for tx = 1, len do
- if bedrockHit then break end
- visitPlaneOptimized(tx, yMin, yMax, zMin, zMax, tx % 2 == 0)
- end
- end
- local function mineQuarry(len, wid, dep, sign)
- -- Quader nach vorne, zur Seite und nach unten.
- -- Jede Ebene wird in einer X/Y-Schlange abgelaufen.
- -- Zwischen den Ebenen startet die naechste Ebene nahe am letzten Punkt.
- blocksTarget = len * wid * dep
- for level = 0, dep - 1 do
- if bedrockHit then break end
- print("")
- print("Ebene " .. (level + 1) .. " / " .. dep)
- local yStart, yEnd, yStep
- if level % 2 == 0 then
- yStart = 0
- yEnd = wid - 1
- yStep = 1
- else
- yStart = wid - 1
- yEnd = 0
- yStep = -1
- end
- local row = 0
- local yi = yStart
- while true do
- local targetY = yi * sign
- local reverseX = (row % 2 == 1)
- if reverseX then
- for tx = len, 1, -1 do
- if not visit(tx, targetY, level) then return end
- end
- else
- for tx = 1, len do
- if not visit(tx, targetY, level) then return end
- end
- end
- if yi == yEnd then break end
- yi = yi + yStep
- row = row + 1
- end
- end
- end
- local function mineRoom(len, wid, hei, sign)
- -- Raum nach vorne, zur Seite und nach oben.
- -- z ist negativ, weil oben.
- blocksTarget = len * wid * hei
- for h = 0, hei - 1 do
- local targetZ = -h
- print("")
- print("Hoehe " .. (h + 1) .. " / " .. hei)
- local yStart, yEnd, yStep
- if h % 2 == 0 then
- yStart = 0
- yEnd = wid - 1
- yStep = 1
- else
- yStart = wid - 1
- yEnd = 0
- yStep = -1
- end
- local row = 0
- local yi = yStart
- while true do
- local targetY = yi * sign
- local reverseX = (row % 2 == 1)
- if reverseX then
- for tx = len, 1, -1 do
- if not visit(tx, targetY, targetZ) then return end
- end
- else
- for tx = 1, len do
- if not visit(tx, targetY, targetZ) then return end
- end
- end
- if yi == yEnd then break end
- yi = yi + yStep
- row = row + 1
- end
- end
- end
- local function mineStaircase(dep, wid)
- -- Treppe nach unten.
- -- Pro Stufe: 1 nach vorne, 1 nach unten.
- -- Hoehe 3, damit man selbst bequem laufen kann.
- local left = math.floor((wid - 1) / 2)
- local right = wid - 1 - left
- blocksTarget = dep * wid * 3
- for step = 1, dep do
- if bedrockHit then break end
- local yMin = -left
- local yMax = right
- -- Um die Stufe herum 3 hoch frei machen.
- -- zBottom ist die aktuelle Stufe, zTop zwei Bloecke darueber.
- local zTop = step - 2
- local zBottom = step
- visitPlaneOptimized(step, yMin, yMax, zTop, zBottom, step % 2 == 0)
- end
- end
- local function mineShaft(size, dep)
- -- Schacht startet VOR der Turtle, damit die Kiste hinter der Turtle sicher bleibt.
- -- 1x1: x=1,y=0
- -- 3x3: x=1..3,y=-1..1
- local radius = math.floor(size / 2)
- local yMin = -radius
- local yMax = radius
- local xMin = 1
- local xMax = size
- blocksTarget = size * size * dep
- for level = 1, dep do
- if bedrockHit then break end
- print("")
- print("Schacht-Ebene " .. level .. " / " .. dep)
- local reverseX = level % 2 == 0
- if reverseX then
- for tx = xMax, xMin, -1 do
- visitPlaneOptimized(tx, yMin, yMax, level, level, tx % 2 == 0)
- end
- else
- for tx = xMin, xMax do
- visitPlaneOptimized(tx, yMin, yMax, level, level, tx % 2 == 0)
- end
- end
- end
- end
- local function mineStripMine(mainLen, branchLen, spacing)
- -- Haupttunnel 1x2.
- -- Alle X Bloecke Seitenarme links und rechts, ebenfalls 1x2.
- blocksTarget = mainLen * 2 + math.floor(mainLen / spacing) * branchLen * 4
- for tx = 1, mainLen do
- if tx % 2 == 1 then
- visit(tx, 0, 0)
- visit(tx, 0, -1)
- else
- visit(tx, 0, -1)
- visit(tx, 0, 0)
- end
- if tx % spacing == 0 then
- local saveX = tx
- -- rechter Seitenarm
- for by = 1, branchLen do
- visit(saveX, by, 0)
- visit(saveX, by, -1)
- end
- -- zur Mitte zurueck
- goTo(saveX, 0, -1)
- -- linker Seitenarm
- for by = -1, -branchLen, -1 do
- visit(saveX, by, -1)
- visit(saveX, by, 0)
- end
- -- zur Hauptstrecke zurueck
- goTo(saveX, 0, 0)
- end
- end
- end
- local function mineChunkQuarry(dep)
- mineQuarry(16, 16, dep, 1)
- end
- -- =========================================================
- -- SETUP
- -- =========================================================
- local function checkChestBehind()
- local old = dir
- turnTo(2)
- local has = turtle.detect()
- turnTo(old)
- if not has then
- print("")
- print("Warnung: Hinter der Turtle wurde kein Block erkannt.")
- return yn("Trotzdem starten", false)
- end
- return true
- end
- local function askFuelAndChestFirst()
- drawSlotPlan()
- clear()
- print("=== Schritt 1: Kiste und Fuel ===")
- print("")
- if not yn("Steht die Kiste direkt hinter der Turtle", nil) then
- print("Bitte Kiste direkt hinter die Turtle stellen und neu starten.")
- return false
- end
- if not yn("Ist Fuel in Slot 2", nil) then
- print("Bitte Fuel in Slot 2 legen und neu starten.")
- return false
- end
- if not checkChestBehind() then
- print("Abbruch.")
- return false
- end
- return true
- end
- local function chooseProgram()
- clear()
- print("=== Schritt 2: Programm waehlen ===")
- print("")
- mode = askChoice("Was soll die Turtle machen?", {
- { label = "Tunnel 1x2, fragt nur Laenge", value = "tunnel_1x2" },
- { label = "Tunnel 3x3, fragt nur Laenge", value = "tunnel_3x3" },
- { label = "Tunnel 5x5, fragt nur Laenge", value = "tunnel_5x5" },
- { label = "Treppe nach unten, fragt Tiefe und Breite", value = "staircase" },
- { label = "Raum ausheben", value = "room" },
- { label = "Schacht 1x1 nach unten", value = "shaft_1x1" },
- { label = "Schacht 3x3 nach unten", value = "shaft_3x3" },
- { label = "Stripmine mit Seitenarmen", value = "stripmine" },
- { label = "Chunk Quarry 16x16", value = "chunk" },
- { label = "Eigenen Bereich: Laenge, Breite, Tiefe", value = "quarry" },
- }, 10)
- end
- local function askProgramQuestions()
- clear()
- print("=== Schritt 3: Masse ===")
- print("")
- if mode == "tunnel_1x2" then
- length = askNumber("Tunnel-Laenge", 1)
- elseif mode == "tunnel_3x3" then
- length = askNumber("Tunnel-Laenge", 1)
- elseif mode == "tunnel_5x5" then
- length = askNumber("Tunnel-Laenge", 1)
- elseif mode == "staircase" then
- depth = askNumber("Treppen-Tiefe nach unten", 1)
- width = askNumber("Treppen-Breite", 1, 3)
- elseif mode == "room" then
- length = askNumber("Raum-Laenge nach vorne", 1)
- sideSign = askChoice("Raum-Breite nach rechts oder links?", {
- { label = "rechts", value = 1 },
- { label = "links", value = -1 },
- }, 1)
- width = askNumber("Raum-Breite", 1)
- height = askNumber("Raum-Hoehe nach oben", 1, 3)
- elseif mode == "shaft_1x1" then
- depth = askNumber("Schacht-Tiefe", 1)
- elseif mode == "shaft_3x3" then
- depth = askNumber("Schacht-Tiefe", 1)
- elseif mode == "stripmine" then
- length = askNumber("Haupttunnel-Laenge", 1)
- width = askNumber("Seitenarm-Laenge", 1, 16)
- depth = askNumber("Abstand zwischen Seitenarmen", 1, 4)
- elseif mode == "chunk" then
- depth = askNumber("Chunk-Quarry-Tiefe", 1)
- elseif mode == "quarry" then
- length = askNumber("Laenge nach vorne", 1)
- sideSign = askChoice("Breite nach rechts oder links?", {
- { label = "rechts", value = 1 },
- { label = "links", value = -1 },
- }, 1)
- width = askNumber("Breite", 1)
- depth = askNumber("Tiefe nach unten", 1)
- end
- end
- local function configureFilters()
- clear()
- print("=== Schritt 4: Material-Filter ===")
- print("")
- cfg.filterMode = askChoice("Material-Filter:", {
- { label = "Alles behalten", value = "all" },
- { label = "Blacklist: nur Trash wegwerfen", value = "blacklist" },
- { label = "Whitelist: nur wichtige Items behalten", value = "whitelist" },
- }, 2)
- if cfg.filterMode == "blacklist" then
- print("")
- print("Trash-Liste konfigurieren:")
- TRASH_ITEMS["minecraft:cobblestone"] = yn("Cobblestone wegwerfen", true)
- TRASH_ITEMS["minecraft:cobbled_deepslate"] = yn("Cobbled Deepslate wegwerfen", true)
- TRASH_ITEMS["minecraft:gravel"] = yn("Gravel wegwerfen", true)
- TRASH_ITEMS["minecraft:sand"] = yn("Sand wegwerfen", true)
- TRASH_ITEMS["minecraft:dirt"] = yn("Dirt wegwerfen", true)
- TRASH_ITEMS["minecraft:flint"] = yn("Flint wegwerfen", true)
- if yn("Granite wegwerfen", false) then add(TRASH_ITEMS, "minecraft:granite") end
- if yn("Diorite wegwerfen", false) then add(TRASH_ITEMS, "minecraft:diorite") end
- TRASH_ITEMS["minecraft:andesite"] = false
- TRASH_ITEMS["minecraft:tuff"] = false
- print("")
- print("Andesite und Tuff werden gesammelt.")
- pause()
- elseif cfg.filterMode == "whitelist" then
- print("")
- print("Whitelist aktiv: Nur Items auf der Sammelliste bleiben im Inventar.")
- if yn("Andesite sammeln", true) then add(KEEP_ITEMS, "minecraft:andesite") end
- if yn("Tuff sammeln", true) then add(KEEP_ITEMS, "minecraft:tuff") end
- if yn("Granite sammeln", false) then add(KEEP_ITEMS, "minecraft:granite") end
- if yn("Diorite sammeln", false) then add(KEEP_ITEMS, "minecraft:diorite") end
- if yn("Cobblestone sammeln", false) then add(KEEP_ITEMS, "minecraft:cobblestone") end
- if yn("Cobbled Deepslate sammeln", false) then add(KEEP_ITEMS, "minecraft:cobbled_deepslate") end
- end
- end
- local function configureAutomation()
- clear()
- print("=== Schritt 5: Automatik / Geschwindigkeit ===")
- print("")
- cfg.throwTrashDown = yn("Trash direkt nach unten werfen", true)
- cfg.stackItems = yn("Items regelmaessig zusammenstacken", true)
- print("")
- cfg.lowFuelReturn = yn("Bei niedrigem Fuel automatisch zur Kiste", true)
- cfg.reserveFuel = askNumber("Fuel-Reserve", 10, 200)
- print("")
- print("Hinweis: Brueckenmodus setzt nur dann Bloecke aus Slot 1,")
- print("wenn unter der Turtle Luft ist.")
- cfg.bridgeMode = yn("Bruecken-/Bodenmodus mit Slot 1 aktivieren", false)
- print("")
- cfg.fluidMode = askChoice("Lava/Wasser-Verhalten:", {
- { label = "Stoppen und auf Enter warten", value = "stop" },
- { label = "Mit Block aus Slot 1 abdichten", value = "seal" },
- { label = "Ignorieren", value = "ignore" },
- }, 1)
- cfg.bedrockStop = yn("Bei Bedrock automatisch stoppen", true)
- print("")
- cfg.maintenanceEvery = askNumber("Trash/Stack-Check alle wie viele Bloecke", 1, 10)
- cfg.progressEvery = askNumber("Fortschritt alle wie viele Bloecke anzeigen", 1, 50)
- end
- local function initialRefuel()
- if fuelUnlimited() then
- print("Fuel ist unlimited.")
- return true
- end
- print("Fuel-Level: " .. tostring(fuel()))
- topUpFuel()
- print("Fuel-Level nach Auto-Refuel: " .. tostring(fuel()))
- if fuel() <= 2 then
- print("Zu wenig Fuel. Lege Fuel in Slot 2.")
- return false
- end
- return true
- end
- local function showSummary()
- clear()
- print("=== Schritt 6: Zusammenfassung ===")
- print("")
- print("Modus: " .. mode)
- if mode == "tunnel_1x2" or mode == "tunnel_3x3" or mode == "tunnel_5x5" then
- print("Laenge: " .. length)
- elseif mode == "staircase" then
- print("Tiefe: " .. depth)
- print("Breite: " .. width)
- elseif mode == "room" then
- print("Laenge: " .. length)
- print("Breite: " .. width)
- print("Hoehe: " .. height)
- print("Richtung: " .. (sideSign == 1 and "rechts" or "links"))
- elseif mode == "shaft_1x1" or mode == "shaft_3x3" then
- print("Tiefe: " .. depth)
- elseif mode == "stripmine" then
- print("Haupttunnel-Laenge: " .. length)
- print("Seitenarm-Laenge: " .. width)
- print("Abstand: " .. depth)
- elseif mode == "chunk" then
- print("Chunk: 16x16")
- print("Tiefe: " .. depth)
- elseif mode == "quarry" then
- print("Laenge: " .. length)
- print("Breite: " .. width)
- print("Tiefe: " .. depth)
- print("Richtung: " .. (sideSign == 1 and "rechts" or "links"))
- end
- print("")
- print("Slot 1: Bau-/Auffuellmaterial")
- print("Slot 2: Fuel")
- print("Slots 3-16: Items")
- print("")
- print("Filter: " .. cfg.filterMode)
- print("Trash nach unten: " .. tostring(cfg.throwTrashDown))
- print("Stacken: " .. tostring(cfg.stackItems))
- print("Fuel-Reserve: " .. cfg.reserveFuel)
- print("Brueckenmodus: " .. tostring(cfg.bridgeMode))
- print("Fluessigkeiten: " .. cfg.fluidMode)
- print("Bedrock-Stopp: " .. tostring(cfg.bedrockStop))
- print("Auto-Crafting: aus")
- print("")
- end
- local function setup()
- setupDefaultLists()
- if not askFuelAndChestFirst() then return false end
- chooseProgram()
- askProgramQuestions()
- configureFilters()
- configureAutomation()
- showSummary()
- return yn("Starten", nil)
- end
- -- =========================================================
- -- START
- -- =========================================================
- local function runSelectedMode()
- startClock = os.clock()
- if mode == "tunnel_1x2" then
- mineTunnel1x2(length)
- elseif mode == "tunnel_3x3" then
- mineTunnel(3, length)
- elseif mode == "tunnel_5x5" then
- mineTunnel(5, length)
- elseif mode == "staircase" then
- mineStaircase(depth, width)
- elseif mode == "room" then
- mineRoom(length, width, height, sideSign)
- elseif mode == "shaft_1x1" then
- mineShaft(1, depth)
- elseif mode == "shaft_3x3" then
- mineShaft(3, depth)
- elseif mode == "stripmine" then
- mineStripMine(length, width, depth)
- elseif mode == "chunk" then
- mineChunkQuarry(depth)
- elseif mode == "quarry" then
- mineQuarry(length, width, depth, sideSign)
- end
- end
- if setup() then
- clear()
- print("Starte optimiertes Mining-Programm...")
- print("")
- if initialRefuel() then
- runSelectedMode()
- print("")
- print("Mining beendet. Fahre zur Kiste...")
- goTo(0, 0, 0)
- dropIntoChest()
- showProgress(true)
- print("")
- print("=== Fertig ===")
- print("Modus: " .. mode)
- print("Bloecke bearbeitet: " .. blocksDone .. " / " .. blocksTarget)
- print("Entladungen: " .. unloads)
- print("Trash gedroppt: ca. " .. trashDropped .. " Items")
- print("Fuel uebrig: " .. tostring(fuel()))
- print("Laufzeit: " .. math.floor(os.clock() - startClock) .. " Sekunden")
- if bedrockHit then
- print("Hinweis: Bedrock wurde erreicht.")
- end
- else
- print("Abbruch wegen Fuel.")
- end
- else
- print("Abbruch.")
- end
Add Comment
Please, Sign In to add comment