Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin get 7ntRFDfp Arch
- local tArgs = { ... }
- if #tArgs ~= 2 then
- print( "Usage: Arch <count> <0|1 start column>" )
- print( "Row 1 should have fuel" )
- print( "Row 2 and 3 should be the outer shell blocks" )
- print( "Row 4 should be the center shell blocks" )
- return
- end
- -- Mine in a quarry pattern until we hit something we can't dig
- local length = 5
- local tall = 4
- local archCount = tonumber( tArgs[1] )
- local startColumn = tonumber( tArgs[2] )
- if archCount < 1 then
- print( "Arch count must be positive" )
- return
- end
- 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=1,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- turtle.select(1)
- return true
- 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()
- 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 tryBack()
- refuel()
- while not turtle.back() do
- sleep( 0.5 )
- end
- return true
- end
- local function placeOuter()
- for n=5,12 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.place() then
- turtle.select(1)
- return true
- end
- end
- end
- turtle.select(1)
- return false
- end
- local function placeInner()
- for n=13,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.place() then
- turtle.select(1)
- return true
- end
- end
- end
- turtle.select(1)
- return false
- 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( "Building..." )
- local function makeOuterPillar(dir)
- for n = 1, tall do
- placeOuter()
- if n < tall then
- if (dir > 0) then
- if not tryUp() then
- return false
- end
- else
- if not tryDown() then
- return false
- end
- end
- end
- end
- end
- local function makeMiddlePillar(dir)
- if dir < 0 then
- placeOuter()
- else
- placeInner()
- end
- if tall > 1 then
- if (dir > 0) then
- if not tryUp() then
- return false
- end
- else
- if not tryDown() then
- return false
- end
- end
- end
- for n = 1, tall - 2 do
- placeInner()
- if (dir > 0) then
- if not tryUp() then
- return false
- end
- else
- if not tryDown() then
- return false
- end
- end
- end
- if tall > 1 then
- if dir > 0 then
- placeOuter()
- else
- placeInner()
- end
- end
- end
- tryForward()
- turtle.turnRight()
- turtle.turnRight()
- local mdir = 1
- if startColumn == 1 then
- makeOuterPillar(mdir)
- tryBack()
- mdir = -1 * mdir
- end
- for n = 1, archCount do
- for l = 2, length - 1 do
- makeMiddlePillar(mdir)
- mdir = -1 * mdir
- tryBack()
- end
- makeOuterPillar(mdir)
- tryBack()
- mdir = -1 * mdir
- end
- print( "Arches complete." )
- print( "Mined "..collected.." items total." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement