Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length=100
- current=0
- barrels={
- "minecraft:cobblestone",
- "minecraft:stone",
- "minecraft:dirt",
- "minecraft:gravel"
- }
- function Dig()
- local success,data=turtle.inspect()
- if success and not (data.name=="computercraft:turtle_expanded") then
- while turtle.detect() do
- turtle.dig()
- end
- end
- end
- function DigUp()
- local success,data=turtle.inspectUp()
- if success and not (data.name=="computercraft:turtle_expanded") then
- turtle.digUp()
- end
- end
- function DigDown()
- local success,data=turtle.inspectDown()
- if success then
- if data.name=="minecraft:bedrock" then return false
- elseif data.name=="computercraft:turtle_expanded" then
- elseif data.name=="minecraft:log" then
- while data.name=="minecraft:log" do
- success,data=turtle.inspectDown()
- end
- else turtle.digDown()
- end
- end
- return true
- end
- function Forward()
- while not turtle.forward() do
- Dig()
- turtle.attack()
- end
- end
- function Up()
- while not turtle.up() do
- DigUp()
- turtle.attackUp()
- end
- end
- function Down()
- while not turtle.down() do
- DigDown()
- turtle.attackDown()
- end
- end
- function Dump()
- local success,data=turtle.inspect()
- if success and data.name=="minecraft:chest" then
- else
- while not (data.name=="minecraft:chest") do
- success,data=turtle.inspect()
- end
- end
- for slot=1,16 do
- turtle.select(slot)
- while not turtle.drop() do turtle.drop() end
- end
- turtle.select(1)
- end
- function CheckWorth(obj)
- for i=1,#barrels do
- if obj==barrels[i] then return false end
- end
- return true
- end
- function DigIfWorth()
- local success,data=turtle.inspect()
- if success and CheckWorth(data.name) then Dig() end
- end
- function DigFace()
- turtle.turnLeft()
- DigIfWorth()
- local depth=0
- while DigDown() do
- Down()
- DigIfWorth()
- depth=depth+1
- end
- turtle.turnRight() turtle.turnRight()
- DigIfWorth()
- for i=1,depth do
- Up()
- DigIfWorth()
- end
- turtle.turnLeft()
- end
- function EmptyInventory(dist)
- turtle.turnRight() turtle.turnRight()
- while current>0 do
- Forward()
- current=current-1
- end
- Down() Down() Down()
- Dump()
- turtle.turnRight() turtle.turnRight()
- Up() Up() Up()
- while current<dist do
- Forward()
- current=current+1
- end
- end
- function DigTunnel()
- while current<length do
- DigFace()
- Dig()
- Forward()
- current=current+1
- if turtle.getItemCount(16)>0 then EmptyInventory(current) end
- end
- EmptyInventory(0)
- end
- function FindPosition()
- turtle.turnLeft()
- while not (turtle.detect()) do
- turtle.forward()
- end
- local success,data=turtle.inspect()
- if success and not (data.name=="computercraft:turtle_expanded") then
- Dig() Forward()
- Dig() Forward()
- Dig() Forward()
- turtle.turnRight()
- DigTunnel()
- else
- turtle.turnRight() sleep(2)
- end
- end
- while true do
- FindPosition()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement