Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hasTorches()
- if ( turtle.getItemCount(16) > 0 ) then
- return true
- else
- return false
- end
- end
- function invFull()
- full=true
- for i=1,16 do
- full = ( turtle.getItemCount(i) > 0 and full )
- end
- return full
- end
- function checkInv()
- if ( invFull() ) then
- print("Inventory Full, Please Empty")
- while ( invFull() ) do
- sleep(1)
- end
- end
- end
- function moveUp()
- while ( not turtle.up() ) do
- turtle.digUp()
- checkInv()
- end
- end
- function moveDown()
- while ( not turtle.down() ) do
- turtle.digDown()
- checkInv()
- end
- end
- function moveForward()
- while ( not turtle.forward() ) do
- turtle.dig()
- checkInv()
- end
- end
- function digForward()
- while ( turtle.detect() ) do
- turtle.dig()
- checkInv()
- end
- end
- function rotate()
- for i=1,2 do
- turtle.turnLeft()
- end
- end
- function digTunnel(height, putTorch)
- for i=1,height-1 do
- checkFuel()
- digForward()
- moveUp()
- if ( height-1 == i and putTorch ) then
- placeTorch()
- end
- end
- moveForward()
- for i=1,height-1 do
- checkFuel()
- digForward()
- moveDown()
- end
- moveForward()
- end
- function placeTorch()
- if ( not hasTorches() ) then
- print("No More Torches, Please replenish")
- while ( not hasTorches() ) do
- sleep(1)
- end
- end
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- function checkFuel()
- if ( turtle.getFuelLevel() < 10 ) then
- print("Fuel Level is less than 10, please place fuel in slot 1")
- turtle.select(1)
- while ( turtle.getFuelLevel() < 10 ) do
- if ( turtle.getItemCount(1) > 0 ) then
- turtle.refuel()
- end
- sleep(1)
- end
- print("Turtle Refuled, Fuel Level = " .. turtle.getFuelLevel())
- end
- end
- args = { ... }
- tunnelHeight=tonumber(args[1])
- tunnelLength=tonumber(args[2])
- for i=1,tunnelLength/2 do
- if ( i % 3 == 1 ) then
- digTunnel(tunnelHeight, true)
- else
- digTunnel(tunnelHeight, false)
- end
- if ( i % 10 == 0 ) then
- output=string.format("%.2f%% of the Tunnel Completed.", i/(tunnelLength/2)*100)
- print(output)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment