Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write("How many levels should I dig: ")
- local levels = tonumber(io.read())
- write("Enter fuel slot (1-9): ")
- local fuelSlot = tonumber(io.read())
- write("Enter torches slot (1-9): ")
- local torchSlot = tonumber(io.read())
- write("Digging a 3x3 for "..levels.." levels!\n")
- function checkFuel()
- if turtle.getFuelLevel() < 5 then
- turtle.select(1)
- if not turtle.refuel(1) then
- error("Out of fuel")
- end
- end
- end
- function placeTorch()
- turtle.select(torchSlot)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- end
- function dig()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function mineLayer()
- dig()
- turtle.forward()
- turtle.turnLeft()
- dig()
- digUp()
- turtle.up()
- dig()
- digUp()
- turtle.up()
- dig()
- turtle.turnRight()
- turtle.turnRight()
- dig()
- turtle.down()
- dig()
- turtle.down()
- dig()
- turtle.turnLeft()
- end
- local levelsSinceTorch = 1
- for i=1,levels do
- checkFuel()
- mineLayer()
- if levelsSinceTorch % 6 == 0 then
- placeTorch()
- end
- levelsSinceTorch = levelsSinceTorch + 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,levels do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- write("Finished mining\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement