Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearInv()
- for i=1,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function getItem(itemName, itemSpotNumber)
- clearInv()
- isCoal = false
- coalSlot = 0
- i = 1
- while not isCoal do
- turtle.select(i)
- turtle.suck()
- data = turtle.getItemDetail()
- if data.name == itemName then
- isCoal = true
- end
- i = i+1
- end
- coalSlot = i
- for i=i-2, 1, -1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(coalSlot-1)
- turtle.transferTo(itemSpotNumber)
- turtle.select(1)
- end
- function gatherDiamond()
- for i = 1, 4 do
- turtle.turnLeft()
- result, data = turtle.inspect()
- if result and data.name == "minecraft:diamond_ore" then
- while turtle.dig() do
- print("Digging!")
- end
- turtle.suck()
- turtle.forward()
- gatherDiamond()
- turtle.back()
- end
- end
- result, data = turtle.inspectUp()
- if result and data.name == "minecraft:diamond_ore" then
- while turtle.digUp() do
- print("digging up!")
- end
- turtle.up()
- gatherDiamond()
- turtle.down()
- end
- result1, data1 = turtle.inspectDown()
- if result1 and data1.name == "minecraft:diamond_ore" then
- while turtle.digDown() do
- print("digging down!")
- end
- turtle.down()
- gatherDiamond()
- turtle.up()
- end
- end
- function placeTorch()
- turtle.select(2)
- turtle.turnLeft()
- turtle.placeUp()
- turtle.turnRight()
- end
- function digMultipleTimes(times)
- for i = 1, times do
- gatherDiamond()
- while not turtle.up() do
- turtle.digUp()
- end
- gatherDiamond()
- while true do
- if not turtle.dig() then
- break
- end
- end
- turtle.down()
- if i % 5 == 0 then
- placeTorch()
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- function digTunnel()
- digMultipleTimes(100)
- turtle.turnRight()
- digMultipleTimes(4)
- turtle.turnRight()
- digMultipleTimes(100)
- end
- function go(i)
- for j = 1, i do
- while true do
- if not turtle.dig() then
- break
- end
- end
- turtle.up()
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.down()
- end
- end
- function mine()
- while true do
- i = 0
- while turtle.getFuelLevel() < 1000 do
- getItem("minecraft:coal", 1)
- turtle.refuel()
- end
- turtle.select(2)
- while turtle.getItemCount() < 50 do
- getItem("minecraft:torch", 2)
- end
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- i = i + 1
- turtle.turnLeft()
- result, data = turtle.inspect()
- while not result do
- turtle.turnRight()
- go(8)
- i = i + 8
- turtle.turnLeft()
- result, data = turtle.inspect()
- end
- digTunnel()
- turtle.turnRight()
- go(4)
- for j = 1, i do
- turtle.forward()
- end
- end
- end
- mine()
Add Comment
Please, Sign In to add comment