Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- depth = 0
- descending = true
- ascending = true
- chestSlot = 1
- function fuel()
- if turtle.getFuelLevel() <= 10 then
- local fuelTable = {"minecraft:coal", "minecraft:lava_bucket"}
- for i = 1, 16, 1 do
- local itemData = turtle.getItemDetail(i)
- for k, v in ipairs(fuelTable) do
- if itemData.name == v then
- turtle.select(i)
- turtle.refuel()
- turtle.select(1)
- end
- end
- end
- end
- end
- function isValuable()
- local junkTable = {"minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:sand", "minecraft:torch"}
- local valuable = true
- local isBlock, blockData = turtle.inspect()
- if isBlock == true then
- print("There's something here. Block data:")
- print(blockData.name)
- print(blockData.metadata)
- for k, v in ipairs(junkTable) do
- if blockData.name == v then
- print("This is junk.")
- valuable = false
- break
- end
- end
- else
- print("There isn't anything here.")
- valuable = false
- end
- if valuable then
- print("There's something valuable here!")
- return true
- else
- print("Nothing interesting here. Moving on")
- return false
- end
- end
- function checkSides()
- for i = 0, 3, 1 do
- if isValuable() then
- turtle.dig()
- end
- turtle.turnRight()
- end
- end
- function isBottomEmpty()
- local isBlock, blockData = turtle.inspect()
- if isBlock then
- return true
- else
- return false
- end
- end
- function isBottomBedrock()
- local isBlock, blockData = turtle.inspectDown()
- if isBlock then
- if blockData.name == "minecraft:bedrock" then
- print("We've hit bedrock!")
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function knightMove()
- if turtle.detect()
- turtle.dig()
- end
- turtle.forward()
- if turtle.detect()
- turtle.dig()
- end
- turtle.forward()
- turtle.turnRight()
- if turtle.detect()
- turtle.dig()
- end
- turtle.forward()
- end
- function chestInInventory()
- local foundChest = false
- for i = 1, 16, 1 do
- local data = getItemDetail(i)
- if data.name == "minecraft:chest" then
- foundChest = true
- end
- end
- if foundChest then
- return true
- else
- return false
- end
- end
- function returnToSurface()
- print("Let's go back up...")
- while depth ~= 0 do
- fuel()
- if turtle.up() then
- depth = depth - 1
- else
- print("Obstruction detected...")
- turtle.digUp()
- end
- end
- end
- print("Checking for chests")
- if not chestInInventory then
- print("No chests found! Continue anyway?")
- print("Y for yes, anything else for no")
- local decision = io.read()
- if decision ~= "y" then
- os.exit()
- end
- end
- print("Let's go!")
- while descending do
- fuel()
- checkSides()
- if isBottomBedrock() then
- descending = false
- break
- end
- turtle.digDown()
- turtle.down()
- depth = depth + 1
- end
- knightMove()
- print("Let's go back up...")
- while ascending do
- fuel()
- checkSides()
- if (depth = 0)
- ascending = false
- break
- end
- turtle.digUp()
- if turtle.up() then
- depth = depth - 1
- else
- print("Obstruction detected...")
- turtle.digUp()
- end
- depth = depth - 1
- end
- print("Chest dumping")
- turtle.select(16)
- turtle.placeDown()
- for a = 1, 14 do
- turtle.select(a)
- turtle.dropDown()
- end
- if turtle.getItemCount(16) < 0 then
- print("Out of chests!! Stopping")
- break
- end
- turtle.select(1)
- print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement