Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- --For this you ned the enderchests from enderStorage as storage and fuel deposit
- rows = 0
- columns = 0
- atHome = false
- if #args == 2 then
- columns = tonumber(args[1])-1
- rows = tonumber(args[2])-1
- end
- if columns == 0 then
- term.clear()
- term.setCursorPos(1, 1)
- io.write("Columns: ")
- columns = tonumber(io.read()) -1
- end
- if rows == 0 then
- term.clear()
- term.setCursorPos(1, 1)
- io.write("Rows: ")
- rows = tonumber(io.read()) -1
- end
- term.clear()
- term.setCursorPos(1, 1)
- while turtle.getItemCount(1) ~= 1 do
- term.setCursorPos(1, 1)
- print("pleas place a enderchest with clear invertory into the first slot")
- sleep(5)
- end
- while turtle.getItemCount(2) ~= 1 do
- term.setCursorPos(1, 1)
- print("pleas place a enderchest with coal in it into the second slot")
- sleep(5)
- end
- rotation = 0
- posX = 0
- posY = 0
- posZ = 0
- maxSlots = 16
- atHome = false
- mode = 0
- statusText = "Diging ..."
- atBedrock = false
- function turnLeft()
- turtle.turnLeft()
- if rotation == 0 then
- rotation = 3
- else
- rotation = rotation - 1
- end
- end
- function turnRight()
- turtle.turnRight()
- if rotation == 3 then
- rotation = 0
- else
- rotation = rotation + 1
- end
- end
- function pullInventarToChest()
- local search = 0
- turtle.dig()
- turtle.dig()
- turtle.select(1)
- turtle.place()
- for search = maxSlots, 3, -1 do
- turtle.select(search)
- turtle.drop()
- end
- turtle.select(1)
- turtle.dig()
- --Wenn inventar nicht geleert werden kann zurueck zum Anfang
- if turtle.getItemCount(16) ~= 0 and turtle.getItemCount(3) ~= 0 then
- statusText = "Inventar full return home"
- return false
- end
- return true
- end
- function refuelFromChest()
- local search = maxSlots
- if not pullInventarToChest() then
- for search = maxSlots, 3, -1 do
- turtle.select(search)
- turtle.refuel(turtle.getItemCount(search))
- end
- statusText = "Inventar full return home"
- info()
- returnHome()
- do return end
- end
- turtle.select(2)
- turtle.place()
- turtle.select(3)
- turtle.suck()
- turtle.refuel(turtle.getItemCount(3))
- turtle.select(2)
- turtle.dig()
- end
- function checkFuel()
- local minFuelLevel = posX + posY + posZ + 1
- if minFuelLevel < 100 then
- minFuelLevel = 100
- end
- if turtle.getFuelLevel() <= minFuelLevel then
- refuelFromChest()
- checkFuel()
- end
- end
- -- Chest Full (true) | Chest empty (false)
- function checkFull()
- local returnment = false
- if turtle.getItemCount(16) ~= 0 then
- returnment = not pullInventarToChest()
- end
- return returnment
- end
- function proofBedrockDown()
- local succes, block = turtle.inspectDown()
- if succes then
- if block.name == "minecraft:bedrock" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function proofBedrockFront()
- local succes, block = turtle.inspect()
- if succes then
- if block.name == "minecraft:bedrock" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function returnHome()
- turnFront()
- while posZ > 0 do
- turtle.up()
- posZ = posZ - 1
- end
- turnLeft()
- while posX > 0 do
- turtle.forward()
- posX = posX - 1
- end
- turnLeft()
- while posY > 0 do
- turtle.forward()
- posY = posY - 1
- end
- atHome = true
- info()
- end
- function info()
- term.clear()
- term.setCursorPos(1, 1)
- print("---------------------------------------")
- print("-----------Made by Magnetar------------")
- print("---------------------------------------")
- print("Mining size: " .. rows + 1 .. " by " .. columns + 1)
- print("")
- print("X: " .. posX .. " Y: " .. posY .. " Z: " .. posZ)
- print("Fuel level: " .. turtle.getFuelLevel())
- print("")
- print("Status: " .. statusText)
- end
- -- Turtle dreht sich nach links
- -- rotation 0 schaut nach vorne
- -- rotation 1 schaut nach rechts
- -- rotation 2 schaut nach hinten
- -- rotation 3 schaut nach links
- function turnFront()
- if rotation == 1 then
- turnLeft()
- elseif rotation == 2 then
- turnLeft()
- turnLeft()
- elseif rotation == 3 then
- turnRight()
- end
- end
- function digForward()
- if checkFull() then
- --auto return home in checkFull Funktion through error
- returnHome()
- return false
- end
- checkFuel()
- if not proofBedrockDown() then
- while turtle.attackDown() do
- end
- turtle.digDown()
- end
- if not proofBedrockFront() then
- while turtle.attack() do
- end
- turtle.dig()
- turtle.dig()
- turtle.forward()
- if rotation == 0 then
- posY = posY + 1
- elseif rotation == 1 then
- posX = posX + 1
- elseif rotation == 2 then
- posY = posY - 1
- elseif rotation == 3 then
- posX = posX - 1
- end
- turtle.digUp()
- info()
- else
- returnHome()
- end
- return true
- end
- function modeTurn()
- if rotation == 1 then
- if posY == 0 then
- turnLeft()
- elseif posY == rows then
- turnRight()
- end
- elseif rotation == 3 then
- if posY == 0 then
- turnRight()
- elseif posY == rows then
- turnLeft()
- end
- else
- sleep(0)
- if rotation == 0 and mode == 0 then
- turnRight()
- elseif rotation == 2 and mode == 1 then
- turnRight()
- elseif rotation == 2 and mode == 0 then
- turnLeft()
- elseif rotation == 0 and mode == 1 then
- turnLeft()
- end
- end
- end
- function minePlane()
- if rotation == 0 then
- while posY < rows do
- if not digForward()then
- return
- end
- end
- elseif rotation == 2 then
- while posY > 0 do
- if not digForward()then
- do return end
- end
- end
- end
- sleep(0)
- if posX ~= columns and mode == 0 then
- modeTurn()
- if digForward() then
- modeTurn()
- end
- elseif posX ~= 0 and mode == 1 then
- modeTurn()
- if digForward() then
- modeTurn()
- end
- end
- return
- end
- function goDown()
- sleep(0)
- -- not go down when at home
- if atHome then
- do return end
- end
- local i = 0
- while i < 4 do
- if not proofBedrockDown() then
- while turtle.attackDown() do
- end
- turtle.digDown()
- turtle.down()
- posZ = posZ + 1
- i = i + 1
- else
- if not atBedrock then
- turtle.up()
- posZ = posZ - 1
- atBedrock = true
- else
- returnHome()
- return
- end
- end
- end
- turtle.up()
- posZ = posZ - 1
- end
- function invertRotation()
- turnLeft()
- turnLeft()
- end
- function quarry()
- while not atHome do
- if mode == 0 then
- while posX < columns and not atHome do
- minePlane()
- end
- minePlane()
- goDown()
- invertRotation()
- mode = 1
- elseif mode == 1 then
- while posX > 0 and not atHome do
- minePlane()
- end
- minePlane()
- goDown()
- invertRotation()
- mode = 0
- end
- end
- end
- quarry()
- print("---------------------------------------")
- print("---------------Finished----------------")
- print("---------------------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement