Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Saving the first coordinate of the turtle BEFORE program starts
- print("Currently saving location!")
- local x1, y1, z1 = gps.locate()
- print("How far do you want me to go mining?\n")
- local length = io.read()
- function checkUp()
- local success, data = turtle.inspectUp()
- if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
- turtle.digUp()
- turtle.up()
- end
- end
- function checkLeft()
- turtle.turnLeft()
- local success, data = turtle.inspect()
- if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnRight()
- end
- end
- function checkRight()
- turtle.turnRight()
- local success, data = turtle.inspect()
- if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
- turtle.dig()
- turtle.forward()
- else
- turtle.turnLeft()
- end
- end
- function checkDown()
- local success, data = turtle.inspectDown()
- if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
- turtle.digDown()
- turtle.Down()
- end
- end
- function checkFront()
- local success, data = turtle.inspect()
- if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
- turtle.dig()
- turtle.forward()
- end
- end
- -- Side note : Kill urself after ur done with this fucking stupid shit mining program
- for a = length, 1, -1
- do
- turtle.dig()
- turtle.forward()
- local xNew, yNew, zNew = gps.locate()
- checkUp()
- checkUp()
- checkUp()
- checkUp()
- for 3, 1, -1
- do
- turtle.down()
- end
- checkLeft()
- checkLeft()
- checkLeft()
- turtle.turnRight()
- for 3, 1, -1
- do
- turtle.forward()
- end
- turtle.turnLeft()
- -- Seperate cuz my mind stupid
- checkDown()
- -- Seperate cuz my mind stupid
- checkLeft()
- -- Seperate cuz my mind stupid
- checkRight()
- end
- -- Saving the coordinaates of the turtle AS SOON AS IT'S DONE mining
- local x2, y2, z2 = gps.locate()
- -- If the new x-coord is less than the first, then go West (vice versa)
- if x2 < x1 then
- goEast = true
- goWest = false
- elseif x2 > x1 then
- goWest = true
- goEast = false
- else
- goEast = false
- goWest = false
- end
- -- If the new y-coord is less than the first, then go Up (vice versa)
- if y2 < y1 then
- goUp = true
- goDown = false
- elseif y2 > y1 then
- goDown = true
- goUp = false
- else
- goDown = false
- goUp = false
- end
- -- If the new z-coord is less than the first, then go North (vice versa)
- if z2 < z1 then
- goSouth = true
- goNorth = false
- elseif z2 > z1 then
- goNorth = true
- goSouth = false
- else
- goSouth = false
- goNorth = false
- end
- -- While a block is in front, dig
- while turtle.detect() == true
- do
- turtle.dig()
- end
- -- Move forward ONCE
- turtle.forward()
- -- Refresh GPS location (for calibrating direction of turtle)
- local x3, y3, z3 = gps.locate()
- -- If the turtle's x-coordinate gets bigger, it is facing East (vice versa)
- if x3 > x2 then
- faceEast = true
- faceWest = false
- faceNorth = false
- faceSouth = false
- elseif x3 < x2 then
- faceWest = true
- faceEast = false
- faceNorth = false
- faceSouth = false
- end
- -- If the turtle's z-coordinate gets bigger, it is facing South (vice versa)
- if z3 > z2 then
- faceSouth = true
- faceNorth = false
- faceEast = false
- faceWest = false
- elseif z3 < z2 then
- faceNorth = true
- faceSouth = false
- faceEast = false
- faceWest = false
- end
- -- Match z-coords to the beginning position
- if ((faceNorth == true and goNorth == true) or (faceSouth == true and goSouth == true)) then
- for a = math.abs(z3 - z1), 1, -1
- do
- while turtle.detect() == true
- do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- if ((faceNorth == true and goSouth == true) or (faceSouth == true and goNorth == true)) then
- turtle.turnRight()
- turtle.turnRight()
- for b = math.abs(z3 - z1), 1, -1
- do
- while turtle.detect() == true
- do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- -- Match x-coords to the beginning position
- if ((faceEast == true and goEast == true) or (faceWest == true and goWest == true)) then
- for c = math.abs(x3 - x1), 1, -1
- do
- while turtle.detect() == true
- do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- if ((faceEast == true and goWest == true) or (faceWest == true and goEast == true)) then
- turtle.turnRight()
- turtle.turnRight()
- for d = math.abs(x3 - x1), 1, -1
- do
- while turtle.detect() == true
- do
- turtle.dig()
- end
- turtle.forward()()
- end
- end
- -- Match y-coords to the beginning position
- if (goUp == true) then
- for e = math.abs(y3 - y1), 1, -1
- do
- while turtle.detectUp() == true
- do
- turtle.digUp()
- end
- turtle.Up()
- end
- end
- if (goDown == true) then
- for f = math.abs(y3 - y1), 1, -1
- do
- while turtle.detectDown() == true
- do
- turtle.digDown()
- end
- turtle.Down()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement