Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Computercraft quarry script
- --(c) jeremiah Lowe 2018
- width = 3 --The width of the hole
- height = 3 --The height of the hole
- depth = 5 --The depth of the hole
- --The inventory slot for the fuel
- fuelSlot = 1
- --The minimum allowed free slots
- allowedFreeSlots = 4
- print("Initializing SmartTurtle")
- if not os.loadAPI("sturtle") then
- print("Failed to load SmartTurtle API")
- end
- sturtle.setFuelSlot(fuelSlot)
- sturtle.setFuelBufferSize(width * height)
- sturtle.enableAutoRefuel()
- sturtle.createHome("original")
- print("Done")
- print("Mining an area of " .. width .. ", " .. height .. ", " .. depth)
- function emptyInventory()
- sturtle.createHome("back")
- sturtle.home("original")
- side = 4
- for i=0,3 do
- sturtle.turnRight()
- e, b = turtle.inspect()
- if e and b.name ~= nil then
- if string.match(string.lower(b.name), "chest") then
- side = sturtle.getDirection()
- break
- end
- end
- end
- if side == 4 then
- error("No chest beside turtle at home position")
- end
- sturtle.pointTo(side)
- for i=1,16 do
- if i ~= fuelSlot then
- turtle.select(i)
- turtle.drop()
- end
- end
- sturtle.home("back")
- end
- function digTurn(left)
- turn = sturtle.turnRight
- if left then turn = sturtle.turnLeft end
- if not turn() then return false end
- if not sturtle.digForward(1) then return false end
- if not turn() then return false end
- return true
- end
- function mineLayer()
- for i=1,height do
- if not sturtle.digForward(width-1) then return false end
- if sturtle.getFreeSlots() < allowedFreeSlots then
- emptyInventory()
- end
- if i ~= height then
- if not digTurn(i % 2 == 0) then return false end
- end
- end
- return true
- end
- sturtle.digForward()
- for i=1,depth do
- sturtle.createHome("layer")
- while not mineLayer() do
- sturtle.home("layer")
- end
- if i ~= depth then --No need here, were done!
- sturtle.home("layer")
- sturtle.digDown()
- end
- end
- sturtle.home("original")
- emptyInventory()
Advertisement
Add Comment
Please, Sign In to add comment