Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mining = true
- clearByValuables = true
- -- if this is true, it throws away everything except valuables, if false it throws away just the rubbish
- valuables =
- {"minecraft:diamond",
- "minecraft:redstone",
- "minecraft:raw_gold",
- "minecraft:raw_iron",
- "minecraft:lapis_lazuli",
- "minecraft:emerald",
- "minecraft:coal",
- "minecraft:quartz",
- "minecraft:ancient_debris",
- "minecraft:raw_copper",
- "minecraft:charcoal"}
- -- add whatever fuel you're using so it doesn't get thrown out
- rubbish =
- {"minecraft:granite",
- "minecraft:andesite",
- "minecraft:diorite"}
- function equip(item)
- for i = 1, 16, 1 do
- if turtle.getItemDetail(i) == item then
- turtle.transferTo(i)
- end
- end
- end
- function sortItems()
- if clearByValuables then
- for i = 1, 16, 1 do
- if turtle.getItemDetail(i) then
- good = false
- for key, var in pairs(valuables) do
- if var == turtle.getItemDetail(i).name then
- good = true
- break
- end
- end
- if not good then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- end
- turtle.select(1)
- else
- for i = 1, 16, 1 do
- if turtle.getItemDetail(i) then
- good = true
- for key, var in pairs(rubbish) do
- if var == turtle.getItemDetail(i).name then
- good = false
- break
- end
- end
- if not good then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- end
- turtle.select(1)
- end
- end
- function inventoryFull()
- full = true
- for i = 1, 16, 1 do
- if not turtle.getItemDetail(i) then
- full = false
- break
- end
- end
- return full
- end
- while mining do
- if turtle.getFuelLevel() <= 0 then
- turtle.refuel()
- mining = false
- end
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- while not turtle.forward() do
- turtle.dig()
- end
- sortItems()
- if inventoryFull() then
- mining = false
- end
- sleep(0)
- end
- if not mining then
- turtle.turnLeft()
- turtle.turnLeft()
- while true do
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.forward()
- hasBlock, data = turtle.inspect()
- if data.name == "minecraft:barrel" then
- break
- end
- sleep(0)
- end
- for i = 1, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
- end
Advertisement
Advertisement