Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local min_empty = 1 -- The least amount of free slots before inv is regarded as full
- local FUEL = 1
- local TORCH = 2
- local FREE = 3
- local torch_interval = 6
- local torch_current = 1
- local pos_total = 0
- local pos_current = 0
- term.clear()
- term.setCursorPos(1, 1)
- function torch()
- torching = true
- turtle.select(TORCH)
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- torching = false
- end
- function full_inv()
- if turtle.getItemCount(16) > 0 then
- return true
- end
- end
- function empty_inv()
- for i=FREE,16 do
- turtle.select(i)
- turtle.dropUp()
- end
- end
- function refuel()
- -- This beast is designed to run on coal
- if turtle.getFuelLevel() <= 20 then
- turtle.select(FUEL)
- return turtle.refuel(1)
- end
- return true
- end
- function mine_chunk()
- print("Mining chunk nr: ")
- print(pos_current)
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- pos_current = pos_current + 1
- pos_total = pos_total + 1
- torch_current = torch_current + 1
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.down()
- turtle.turnLeft()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.turnRight()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.down()
- turtle.turnLeft()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.turnRight()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.down()
- turtle.turnLeft()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.turnRight()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.down()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- print("Mined chunk nr: ")
- print(pos_current)
- end
- function return_and_empty()
- print("Emptying...")
- while pos_current ~= 0 do
- turtle.back()
- pos_current = pos_current - 1
- end
- empty_inv()
- while pos_current ~= pos_total do
- turtle.forward()
- pos_current = pos_current + 1
- end
- print("Emptied. Returning")
- end
- function main_loop()
- -- refuel()
- mine_chunk()
- if full_inv() == true then
- return_and_empty()
- end
- if torch_current == torch_interval then
- torch()
- torch_current = 1
- end
- main_loop()
- end
- print("Starting the tunnel")
- main_loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement