Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 0
- z = 0
- checks = 0
- chestsDropped = 0
- mined = 0
- function getCount()
- count = 0
- for i = 3,16,1 do
- count = count + turtle.getItemCount(i)
- end
- return count
- end
- function deposit()
- turtle.select(1)
- turtle.turnLeft()
- turtle.dig()
- turtle.digUp()
- turtle.up()
- turtle.dig()
- turtle.down()
- turtle.place()
- chestsDropped = chestsDropped + 1
- for i = 3,16,1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- end
- function checkWanted()
- success, data = turtle.inspect()
- if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
- print("I found ", data.name, "!")
- return true
- end
- end
- function checkWantedUp()
- success, data = turtle.inspectUp()
- if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
- print("I found ", data.name, "!")
- return true
- end
- end
- function checkWantedDown()
- success, data = turtle.inspectDown()
- if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
- print("I found ", data.name, "!")
- return true
- end
- end
- function check()
- print("I'm gonna check for some ore!")
- print("Checking in front of me!")
- if checkWanted() then
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- checks = checks + 1
- check()
- turtle.back()
- checks = checks - 1
- end
- print("Checking to my left!")
- turtle.turnLeft()
- if checkWanted() then
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- checks = checks + 1
- check()
- turtle.back()
- checks = checks - 1
- end
- print("Checking to my right!")
- turtle.turnRight()
- turtle.turnRight()
- if checkWanted() then
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- checks = checks + 1
- check()
- turtle.back()
- checks = checks - 1
- end
- turtle.turnLeft()
- print("Checking above me!")
- if checkWantedUp() then
- turtle.digUp()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- checks = checks + 1
- check()
- turtle.down()
- checks = checks - 1
- end
- print("Checking below me!")
- if checkWantedDown() then
- turtle.digDown()
- turtle.down()
- checks = checks + 1
- check()
- turtle.up()
- checks = checks - 1
- end
- end
- function mine()
- turtle.select(1)
- print("I have ", getCount(), " items.")
- if turtle.detect() == true then
- turtle.dig()
- end
- for a = 1, h-1, 1 do
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.up() then
- y = y + 1
- end
- if turtle.detect() == true then
- turtle.dig()
- end
- end
- check()
- while y > 0 do
- if turtle.down() then
- y = y - 1
- end
- check()
- end
- if turtle.detectDown() == false then
- turtle.select(2)
- turtle.placeDown()
- end
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- z = z + 1
- if getCount() > 320 then
- deposit()
- end
- if z > 0 then
- print("I'm ", z,"/", l, " of the way done.")
- end
- end
- function sideMine()
- turtle.select(1)
- print("I have ", getCount(), " items.")
- if turtle.detect() == true then
- turtle.dig()
- end
- for a = 1, h-1, 1 do
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.up() then
- y = y + 1
- end
- if turtle.detect() == true then
- turtle.dig()
- end
- end
- check()
- while y > 0 do
- if turtle.down() then
- y = y - 1
- end
- check()
- end
- if turtle.detectDown() == false then
- turtle.select(2)
- turtle.placeDown()
- end
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- x = x + 1
- if getCount() > 320 then
- deposit()
- end
- end
- print("+-------------------------------------+")
- print("| Branch Mine |")
- print("+-------------------------------------+")
- print("| Slot 1: Chests |")
- print("| Slot 2: Blocks |")
- print("+-------------------------------------+")
- print("| Place turtle at start of mine. |")
- print("| Insert fuel. Specify height and |")
- print("| length. Press enter to start. |")
- print("+-------------------------------------+")
- read()
- print("+-------------------------------------+")
- print("| Mine length = ? |")
- print("+-------------------------------------+")
- l = tonumber(read())
- print("+-------------------------------------+")
- print("| Mine height = ? (>=2) |")
- print("+-------------------------------------+")
- h = tonumber(read())
- print("+-------------------------------------+")
- print("| Amount of shafts = ? |")
- print("+-------------------------------------+")
- m = tonumber(read())
- while z < l do
- mine()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while z > 0 do
- turtle.dig()
- turtle.forward()
- z = z - 1
- end
- turtle.turnLeft()
- mined = mined + 1
- while mined < m do
- sideMine()
- sideMine()
- sideMine()
- turtle.turnLeft()
- while z < l do
- mine()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while z > 0 do
- turtle.dig()
- turtle.forward()
- z = z - 1
- end
- turtle.turnLeft()
- mined = mined + 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while x > 0 do
- turtle.dig()
- turtle.forward()
- x = x - 1
- end
- turtle.turnRight()
- print("I put down ", chestsDropped, " chests for you.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement