Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- junk = {"granite","andesite","dirt", "stone","gravel","diorite", "grass_block", "flint", "cobblestone","bedrock", "lapis", "gold"}
- depth = 0
- function valuable()
- if (turtle.inspect()) then
- local succ, data = turtle.inspect()
- data.name = data.name:gsub("minecraft:", "")
- if (string.match(data.name, "_ore")) then
- data.name = data.name:gsub("_ore", "")
- shell.run("data "..data.name.." 1")
- turtle.dig()
- end
- end
- end
- function checkWalls()
- for i = 1, 4 do
- valuable()
- turtle.turnRight()
- end
- end
- function mine()
- while (turtle.getFuelLevel() <= 130) do
- turtle.turnRight()
- end
- while turtle.down() do end
- depth = 0
- while (turtle.inspectDown() or turtle.down()) do
- depth = depth + 1
- local success, data = turtle.inspectDown()
- if (data.name == "minecraft:bedrock") then
- break
- elseif (data.name == "minecraft:water" or data.name == "minecraft:flowing_water" or data.name == "minecraft:lava") then
- turtle.down()
- else
- turtle.digDown()
- end
- checkWalls()
- end
- organize()
- for i = 1, depth do
- turtle.up()
- end
- turtle.select(1)
- turtle.placeDown()
- end
- function organize()
- turtle.up()
- depth = depth - 1
- inventory = {}
- for i = 2,16 do
- if (turtle.getItemDetail(i)) then
- data = turtle.getItemDetail(i)
- data["slot"] = i
- table.insert(inventory,data)
- end
- end
- for key, valu in pairs(inventory) do
- if (isJunk(inventory[key].name)) then
- turtle.select(inventory[key].slot)
- turtle.dropDown()
- end
- end
- end
- function isJunk(input)
- local _match
- for key, valu in pairs(junk) do
- if (input == "minecraft:"..junk[key]) then
- _match = true
- end
- end
- if (_match) then
- return true
- else
- return false
- end
- end
- function main()
- while true do
- mine()
- depo()
- pathing()
- end
- end
- function depo()
- if (turtle.getItemDetail(16)) then
- if (turtle.getItemDetail(16).name == "minecraft:chest" and turtle.getItemDetail(11)) then
- turtle.select(16)
- turtle.placeUp()
- for i = 2,15 do
- if (turtle.getItemDetail(i)) then
- turtle.select(i)
- turtle.dropUp()
- end
- end
- end
- else
- print("Out of chests")
- while true do
- turtle.turnRight()
- end
- end
- end
- function pathing()
- turtle.turnRight()
- pathDetect()
- turtle.forward()
- pathDetect()
- turtle.forward()
- turtle.turnLeft()
- pathDetect()
- turtle.forward()
- end
- function pathDetect()
- while turtle.detect() do
- if (turtle.up()) then
- else
- turtle.digUp()
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement