FireDemonite icon

Single line Quarry till bedrock

FireDemonite | PRO | 12/08/20 05:28:15 PM UTC | 0 ⭐ | 141 👁️ | Never ⏰ | []
Lua |

2.05 KB

|

None

|

0 👍

/

0 👎

local function forward()
    turtle.forward()
end
 
local function back()
    turtle.back()
end
 
local function left()
    turtle.turnLeft()
end
 
local function right()
    turtle.turnRight()
end
 
local function up()
    turtle.up()
end
 
local function down()
    turtle.down()
end
 
 
if os.loadAPI("goto.lua") then 
    forward = goto.forward
    back = goto.back
    left = goto.left
    right = goto.right
    up = goto.up
    down = goto.down
end
 
local function shaftDown()
    height = 0
    first = 0
    for i = 1,255 do
        t = turtle.digDown()
        if t and (first == 0) then first = i end
        if not down() then return {vDown = i-1, first = first} end
    end
end
 
local function shaft(p)
    turtle.select(1)
    r = shaftDown()
    turtle.select(1)
    for i = 1,r.vDown do
        up()
        if i > r.vDown-r.first-7 then
            if turtle.getItemCount(1) < r.vDown-i then turtle.select(2) end
            turtle.placeDown()    
        end
        if (p > 0) then turtle.placeDown() end
        turtle.select(1)
    end
end
 
function digShaft(v,p)
    if v == nil then v = 1 end
    if p == nil then p = 0 end
    right()
    right()
    t,item = turtle.inspect()
    while not t do
        t,item = turtle.inspect()
        textutils.slowPrint("Please place a chest...")
        sleep(5)
    end
    left()
    left()
    for i = 1,v do
        shaft(p)
        for s = 1,i-1 do back() end
        for p = 1,2 do right() end
        for i = 1,16 do 
            turtle.select(i)
            t,m = turtle.drop()
            while not t and m == nil do 
                t,m = turtle.drop()
                textutils.slowPrint("Please empty the chest...")
                sleep(5)
            end
        end
        for p = 1,2 do left() end
        if v > 1 then for s = 1,i do forward() end end
    end
end
 
args = {...}
 
if args[1] ~= nil and args[2] ~= nil then
    digShaft(tonumber(args[1]), tonumber(args[2]))
elseif args[1] ~= nil then
    digShaft(tonumber(args[1]))
end

Comments