Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local scriptName = "quarry"
- if #args < 2 then
- print("Usage: " .. scriptName .. " <turtle y coordinate> <height to start mining>")
- return
- end
- local startingHeight = tonumber(args[1])
- local miningStart = tonumber(args[2])
- local chunkSize = 32
- dofile("turtle_bot")
- local t = TurtleBot.new(scriptName, "North")
- t:connect()
- local function mine(direction)
- direction = direction or "front"
- local detect = turtle.detect
- if direction == "up" then
- detect = turtle.detectUp
- elseif direction == "down" then
- detect = turtle.detectDown
- end
- while detect() do t:dig(direction) end
- local inventory = t:inventory()
- if #inventory > 10 then
- t:enderDeposit(COLOR_CHANNELS.miningDepot, {})
- t:dig("up")
- end
- end
- local function mineRow(steps)
- t:updateData()
- for _ = 1, steps do
- mine()
- t:enderRefuel(2000, 5000, ITEMS.charcoal)
- t:dig("up")
- t:forward()
- end
- end
- local function handleTurn(layer, idx)
- local evenLayer = layer % 2 == 0
- local turn = nil
- if idx % 2 == 1 ~= evenLayer then
- turn = function() t:right() end
- else
- turn = function() t:left() end
- end
- turn()
- mine()
- t:forward()
- turn()
- end
- local function mineLayer(layer)
- for idx = 1, chunkSize do
- mineRow(chunkSize - 1)
- if idx ~= chunkSize then
- handleTurn(layer, idx)
- else
- t:left(2)
- end
- end
- end
- local function main()
- t:awaitInventory(ITEMS.enderChest)
- for layer = 1, startingHeight do
- if startingHeight - layer >= miningStart then
- t:dig("down")
- t:down()
- else
- mineLayer(layer)
- if layer ~= startingHeight then
- mine("down")
- t:down()
- end
- end
- end
- for i = 1, startingHeight + 2 do
- t:dig("up")
- t:up()
- end
- end
- t:execute(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement