Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("turtleLib")
- function setupTorchesInInventory()
- local torchesPresent = false
- local previousSlot = turtle.getSelectedSlot()
- local torchesIndex = searchInventoryForItem("minecraft:torch")
- if torchesIndex > -1 then
- torchesPresent = true
- turtle.select(torchesIndex)
- turtle.transferTo(16)
- turtle.select(previousSlot)
- end
- return torchesPresent
- end
- function placeTorch()
- if turtle.getItemDetail(16) ~= nil then
- if turtle.getItemDetail(16).name == "minecraft:torch" then
- local previousSlot = turtle.getSelectedSlot()
- local torchIndex = searchInventoryForItem("minecraft:torch")
- turtle.select(torchIndex)
- turtle.placeUp()
- turtle.select(previousSlot)
- end
- end
- end
- local torches = setupTorchesInInventory()
- local depth = 0;
- -- Dig forward a couple blocks for a doorway
- turtle.dig()
- goForward()
- turtle.digUp()
- turtle.dig()
- goForward()
- turtle.digUp()
- turtle.digDown()
- -- Start digging the stairway
- local success, data = turtle.inspectDown()
- while data.name ~= "minecraft:bedrock" do
- turtle.dig()
- goForward()
- turtle.digUp()
- if (depth%5)==0 then
- placeTorch()
- end
- turtle.digDown()
- goDown()
- turtle.digDown()
- depth = depth + 1
- success, data = turtle.inspectDown()
- end
- -- Continue until reaching bedrock
- -- turn around
- turtle.turnRight()
- turtle.turnRight()
- local stairsIndex = searchInventoryForItem("minecraft:cobblestone_stairs")
- local stairsPresent = (stairsIndex > -1)
- -- Return to surface
- for i=1, depth do -- fixme. use for loop and counter
- goForward()
- -- if stairs present in inventory
- if stairsPresent then
- local preselectedSlot = turtle.getSelectedSlot()
- local itemDetail = turtle.getItemDetail(stairsIndex)
- -- Because staircase can be more than 64 deep...
- -- Make sure we still have stairs selected
- if(itemDetail == nil or itemDetail.name ~= "minecraft:cobblestone_stairs") then
- stairsIndex = searchInventoryForItem("minecraft:cobblestone_stairs")
- stairsPresent = (stairsIndex > -1)
- end
- turtle.select(stairsIndex)
- turtle.digDown()
- turtle.placeDown()
- -- check to make sure stairs are right side up
- local success, data = turtle.inspectDown()
- if success and data.state.half == "top" then
- -- stair is upsidown
- turtle.digDown()
- goDown()
- local fillerBlockIndex = searchInventoryForItem("minecraft:cobblestone")
- if fillerBlockIndex > -1 then
- turtle.select(fillerBlockIndex)
- else
- fillerBlockIndex = searchInventoryForItem("minecraft:cobbled_deepslate")
- if fillerBlockIndex > -1 then
- turtle.select(fillerBlockIndex)
- end
- end
- turtle.placeDown()
- goUp()
- turtle.select(stairsIndex)
- turtle.placeDown()
- end
- if(i==depth) then
- turtle.dig()
- turtle.place()
- end
- turtle.select(preselectedSlot)
- else
- end
- -- endif
- goUp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement