Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin get JWrTxV1z MakeRoom
- --pastebin get SpEd82Jp StripLayer
- --pastebin get 7JMXTNu5 TallTunnel
- local tArgs = { ... }
- if #tArgs ~= 2 then
- print( "Usage: TallTunnel <length> <height>" )
- print( "Slot 1 should be a non-wood floor block" )
- print( "Slot 2 should be a fuel" )
- print( "Slot 3 should be a stack of chests" )
- print( "Slot 4 should be a stack of torches" )
- return
- end
- -- Mine in a quarry pattern until we hit something we can't dig
- local length = tonumber( tArgs[1] )
- local tall = tonumber( tArgs[2] )
- if length < 1 then
- print( "Tunnel length must be positive" )
- return
- end
- if tall < 1 then
- print( "Tunnel height must be positive" )
- return
- end
- local depth = 0
- local collected = 0
- local unloaded = 0
- local function collect()
- collected = collected + 1
- if math.fmod(collected, 25) == 0 then
- print( "Mined "..collected.." items." )
- end
- end
- local function isFull()
- local bFull = true
- local nTotalItems = 0
- for n=1,16 do
- local nCount = turtle.getItemCount(n)
- if nCount == 0 then
- bFull = false
- end
- nTotalItems = nTotalItems + nCount
- end
- if bFull then
- print( "No empty slots left." )
- return true
- end
- return false
- end
- local function unload()
- print( "Unloading items..." )
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(3)
- turtle.place()
- --1: Flooring
- --2: Fuel
- --3: Chests
- --4: Torches
- for n=5,16 do
- unloaded = unloaded + turtle.getItemCount(n)
- turtle.select(n)
- turtle.drop()
- end
- --collected = 0
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- end
- local function tryDig()
- while turtle.detect() do
- if turtle.dig() then
- collect()
- sleep(0.5)
- else
- return false
- end
- end
- return true
- end
- local function tryDigUp()
- while turtle.detectUp() do
- if turtle.digUp() then
- collect()
- sleep(0.5)
- else
- return false
- end
- end
- return true
- end
- local function refuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" or fuelLevel > 0 then
- return
- end
- local function tryRefuel()
- for n=2,16 do
- if n ~= 3 and n ~= 4 then
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- turtle.select(1)
- return true
- end
- end
- end
- end
- turtle.select(1)
- return false
- end
- if not tryRefuel() then
- print( "Add more fuel to continue." )
- while not tryRefuel() do
- sleep(1)
- end
- print( "Resuming Tunnel." )
- end
- end
- local function tryUp()
- refuel()
- while not turtle.up() do
- if turtle.detectUp() then
- if not tryDigUp() then
- return false
- end
- elseif turtle.attackUp() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- local function tryDown()
- refuel()
- while not turtle.down() do
- if turtle.detectDown() then
- if not tryDigDown() then
- return false
- end
- elseif turtle.attackDown() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- local function tryForward()
- refuel()
- if isFull() then
- unload()
- end
- while not turtle.forward() do
- if turtle.detect() then
- if not tryDig() then
- return false
- end
- elseif turtle.attack() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- local function hallway(hallLength)
- for n=1,hallLength do
- turtle.placeDown()
- turtle.turnLeft()
- tryDig()
- for m=2, tall do
- tryDigUp()
- tryUp()
- tryDig()
- end
- turtle.turnRight()
- turtle.turnRight()
- tryDig()
- for m=2, tall do
- tryDown()
- tryDig()
- end
- if math.fmod(n, 6) == 0 then
- turtle.select(4)
- turtle.place()
- turtle.select(1)
- end
- turtle.turnLeft()
- if n<hallLength then
- tryDig()
- if not tryForward() then
- return false
- end
- else
- return true
- end
- end
- end
- print( "Tunnelling..." )
- hallway(length)
- print( "Tunnel complete." )
- print( "Mined "..collected.." items total." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement