Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local max_depth = 64
- local max_width = 64
- local fuel_estimate = max_depth * 2 + 2 * max_width
- function forward(dig)
- while not turtle.forward() do
- if dig then
- block, data = turtle.inspect()
- if block and data.name ~= "computercraft:turtle_normal" then
- turtle.dig()
- end
- else
- print("Waiting in queue......")
- end
- end
- end
- function up(dig)
- while not turtle.up() do
- if dig then
- turtle.digUp()
- else
- print("Waiting in queue......")
- end
- end
- end
- function down(dig)
- while not turtle.down() do
- if dig then
- turtle.digDown()
- else
- print("Waiting in queue......")
- end
- end
- end
- print("Waiting for fuel...")
- while true do
- turtle.suckDown(1)
- turtle.refuel(1)
- if turtle.getFuelLevel() >= fuel_estimate then
- print("We have enough fuel to go mining!")
- break
- end
- end
- local width = 0
- for i=1, max_width / 2 do
- forward(true)
- width = width + 1
- print("Looking for free mining spot at width=" .. width)
- if turtle.detectDown() then
- print("Free spot at width=" .. width .. "!")
- break
- end
- end
- turtle.digDown()
- up()
- local highspot = width % 2 == 1
- if highspot then
- print("Going up to high mining spot")
- for i=1, 3 do
- up(true)
- end
- end
- turtle.turnLeft()
- for depth=1, max_depth do
- forward(true)
- turtle.digUp()
- turtle.digDown()
- print("Mining out, depth=" .. depth)
- end
- print("Gone far enough out, mining back")
- if highspot then
- turtle.turnLeft()
- forward(true)
- width = width - 1
- turtle.turnLeft()
- else
- turtle.turnRight()
- forward(true)
- width = width + 1
- turtle.turnRight()
- end
- for i=1, max_depth do
- turtle.digUp()
- turtle.digDown()
- forward(true)
- print("Mining back, depth=" .. (max_depth - i))
- end
- turtle.digUp()
- turtle.digDown()
- print("Mining done, returning to station")
- turtle.turnRight()
- if highspot then
- print("Going down from high mining spot")
- for i=1, 3 do
- down()
- end
- end
- for i=1, width do
- forward()
- end
- for i=1, 16 do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- down()
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment