Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function digUpDown()
- -- Dig up
- if turtle.detectUp() then
- turtle.digUp()
- end
- -- Dig down
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function digAndMove()
- if turtle.detect() then
- turtle.dig()
- end
- digUpDown()
- turtle.forward()
- end
- function placeTorch(forward)
- turtle.select(2)
- if forward == true then
- if turtle.detect() then
- turtle.dig()
- end
- turtle.place()
- else
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.placeDown()
- end
- end
- function mineAdjacent(torch, torchSide)
- digAndMove()
- turtle.turnLeft()
- digAndMove()
- if torch == true and torchSide == 3 then
- placeTorch(false)
- end
- digAndMove()
- if torch == true and torchSide == 1 then
- placeTorch(true)
- end
- turtle.turnRight()
- digAndMove()
- turtle.turnRight()
- digAndMove()
- digAndMove()
- digUpDown()
- if torch == true and torchSide == 0 then
- placeTorch(true)
- end
- turtle.turnLeft()
- end
- -- Command Line Arguments
- tArg = {...}
- local len = 0
- local torchSide = 0 -- 0=left 1=right 3=under 4=nothing
- if #tArg == 0 then
- print("Slot #1 Coal, Slot #2 Torch")
- print("Torches on right side default")
- print("Input Mining Dimension")
- len = io.read()
- else
- if #tArg >= 1 then
- len = tonumber(tArg[1])
- end
- if #tArg >= 2 then
- torchSide = tonumber(tArg[2])
- end
- end
- local coalUsed = 1;
- turtle.select(1)
- turtle.refuel(1)
- for i=1, len do
- print("Mining adjacent!")
- if i % 2 == 0 then
- mineAdjacent(true, torchSide)
- else
- mineAdjacent(false, 0)
- end
- if turtle.getFuelLevel() == 1 then
- print("Refueling")
- turtle.select(1)
- turtle.refuel(4)
- coalUsed = coalUsed + 1
- end
- end
- print("Total coal spent: ", coalUsed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement