Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wallItem = 1 --Top left slot
- local ladder = 2 --Top middle slot
- local invStart = 3 --Top right slot
- local function unload( _bKeepOneFuelStack )
- print( "Unloading items..." )
- for n=invStart,16 do
- if n ~= placeItem then
- turtle.select(n)
- turtle.refuel(0)
- turtle.drop()
- end
- end
- end
- local function isFull()
- for n=invStart,16 do
- if turtle.getItemCount(n) == 0 then
- --Empty slots
- return false;
- end
- end
- print( "No empty slots left." )
- return true;
- end
- function refuel( ammount )
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" then
- return true
- end
- if turtle.getFuelLevel() < 1 then
- for n=invStart,16 do
- turtle.select(n)
- if turtle.refuel(0) then
- return true
- end
- end
- return false
- end
- return true
- end
- local function wallAround( slot )
- turtle.select(slot)
- for n=1,4 do
- if not turtle.detect() then
- if turtle.getItemCount() == 0 then
- print("Out of wall items")
- error("Out of wall items")
- else
- turtle.place()
- end
- end
- turtle.turnLeft()
- end
- end
- local function tryDown()
- if not refuel() then
- print( "Not enough Fuel" )
- end
- while not turtle.down() do
- if not turtle.digDown() then
- if isFull() then
- unload()
- elseif turtle.attackDown() then
- -- Do Nothing
- else
- sleep( 0.5 )
- end
- end
- end
- return true
- end
- -----------------------------------------------------------------------------
- --Main Program
- -----------------------------------------------------------------------------
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "My Version Usage: shaft depth" )
- return
- end
- local depth = tonumber( tArgs[1] )
- if not refuel() then
- print( "Out of Fuel" )
- return
- end
- print( "Digging a shaft" )
- for shaftDepth=1,depth do
- print("Shafting " .. shaftDepth .. " / " .. depth)
- wallAround(wallItem)
- tryDown()
- turtle.select(ladder)
- turtle.placeUp()
- end
- print( "Done" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement