Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local areasToMine = tonumber(tArgs[1])
- if #tArgs < 1 then
- areasToMine = 1
- print(" Defaulting to 1 areas to mine")
- end
- -- Slot Variables
- lastMiningSlot = 11
- numberOfMiningSlots = lastMiningSlot
- torchSlot = 12
- anchorSlot = 13
- chestSlot = 14
- outputSlot = 15
- fuelChestSlot = 16
- -- Mining Variables
- layer = 0
- line = 0
- -- Inventory variables
- room = 0
- function fuel()
- while turtle.getFuelLevel() < 1000 do
- -- Deposit inventory contents in the chest
- turtle.digDown()
- turtle.select(chestSlot)
- turtle.placeDown()
- turtle.select(lastMiningSlot)
- turtle.dropDown()
- --
- -- Use fuel from fuel Chest
- turtle.digUp()
- turtle.select(fuelChestSlot)
- turtle.placeUp()
- turtle.suckUp()
- turtle.refuel()
- turtle.digUp()
- --
- -- Retrieve chest & its contents
- turtle.select(lastMiningSlot)
- turtle.suckDown()
- turtle.select(chestSlot)
- turtle.digDown()
- --
- turtle.select(1)
- end
- end
- function empty()
- turtle.digUp()
- turtle.select(outputSlot)
- turtle.placeUp()
- for i = 1,numberOfMiningSlots do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(outputSlot)
- turtle.digUp()
- turtle.select(1)
- end
- function inv()
- for i = 1,numberOfMiningSlots do
- if turtle.getItemCount(i) == 0 then
- room = room + 1
- end
- end
- if room == 0 then
- empty()
- else
- room = 0
- end
- end
- function forward()
- while not turtle.forward() do
- inv()
- if not turtle.dig() then
- turtle.attack()
- end
- end
- end
- function up()
- while not turtle.up() do
- inv()
- turtle.digUp()
- end
- end
- function down()
- while not turtle.down() do
- inv()
- turtle.digDown()
- end
- end
- function updown()
- inv()
- turtle.digUp()
- inv()
- turtle.digDown()
- end
- function turnLeft()
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- end
- function turnRight()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- end
- function moveToChunkAbove()
- for i=1,3 do
- up()
- end
- layer = layer + 1
- end
- function moveToChunkBelow()
- for i=1,3 do
- down()
- end
- layer = layer - 1
- end
- function moveToChunkRight()
- for i=1,5 do
- forward()
- end
- turtle.turnRight()
- forward()
- turtle.turnRight()
- line = line + 1
- end
- function moveToChunkLeft()
- for i=1,2 do
- turtle.turnLeft()
- end
- forward()
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- line = line + 1
- end
- function returnToOrigin()
- for i=1,2 do
- turtle.turnLeft()
- end
- for i=1,6 do
- forward()
- end
- turtle.turnLeft()
- for i=1,12 do
- forward()
- end
- turtle.turnLeft()
- line = 0
- end
- function placeTorch()
- turtle.digDown()
- turtle.select(torchSlot)
- turtle.placeDown()
- turtle.select(1)
- end
- function mineLine()
- updown()
- for i=1,2 do
- forward()
- updown()
- end
- end
- function mineChunk()
- torchPlaced = 0
- for i=1,2 do
- mineLine()
- -- if torchPlaced == 0 and layer == 0 and line % 2 == 0 then
- -- placeTorch()
- -- torchPlaced = 1
- -- end
- turnLeft()
- mineLine()
- if torchPlaced == 0 and layer == 0 and line % 2 ~= 0 then
- placeTorch()
- torchPlaced = 1
- end
- turnRight()
- end
- end
- function mineThickLine()
- for i=1,3 do
- mineChunk()
- end
- end
- function mineLayer()
- if layer == 0 then
- setAnchor()
- end
- mineThickLine()
- if layer == 0 then
- setAnchor()
- end
- moveToChunkRight()
- mineThickLine()
- moveToChunkLeft()
- mineThickLine()
- returnToOrigin()
- end
- function mineArea()
- for i=1,3 do
- mineLayer()
- moveToChunkAbove()
- end
- for i=1,9 do
- down()
- end
- end
- function moveToNextArea()
- getAnchor()
- turtle.select(1)
- turtle.turnLeft()
- for i=1,12 do
- forward()
- end
- turtle.turnRight()
- layer = 0
- line = 0
- end
- function setAnchor()
- turtle.turnRight()
- forward()
- turtle.select(anchorSlot)
- if not turtle.compareDown() then
- turtle.digDown()
- turtle.placeDown()
- turtle.select(1)
- end
- for i=1,2 do
- turtle.turnRight()
- end
- forward()
- turtle.turnRight()
- end
- function getAnchor()
- turtle.turnRight()
- forward()
- turtle.select(anchorSlot)
- turtle.digDown()
- turtle.select(1)
- for i=1,2 do
- turtle.turnRight()
- end
- forward()
- turtle.turnRight()
- end
- turtle.select(1)
- for i=1,areasToMine do
- fuel()
- mineArea()
- moveToNextArea()
- end
Advertisement
Add Comment
Please, Sign In to add comment