Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle Miner
- -- by SparkyBearBomb
- --
- -- feel free to use this code
- --
- -- edit mining constraints here
- local X = 16 -- Forward and Backwards (away from placed position)
- local Y = 20 -- Up and Down
- local Z = 16 -- Left and Right
- -- X and Z are set for a chunk size (16 blocks)
- -- use F9 key to see chunk borders
- -- ensure the first block is pre mined by hand
- -- coal will be required in slot 1
- -----------------------------------------------
- --Turtle Miner - Version History
- --
- -- Version 1.1 - 18 AUG 17
- -- - Initial Version Release
- -----------------------------------------------
- x = 1
- y = 1
- z = 1
- running = "yes"
- direction = "up"
- function mineX()
- while turtle.detect() == true do
- turtle.dig()
- end
- turtle.forward()
- x = x + 1
- end
- function mineZ()
- while turtle.detect() == true do
- turtle.dig()
- end
- turtle.forward()
- z = z + 1
- end
- function mineY()
- turtle.turnRight()
- while z > 1 do
- data()
- turtle.forward()
- z = z - 1
- end
- turtle.turnRight()
- if turtle.detectDown() == true then
- turtle.digDown()
- end
- turtle.down()
- y = y + 1
- direction = "up"
- x = 1
- z = 1
- end
- function finished()
- while y > 1 do
- turtle.up()
- y = y - 1
- data()
- end
- turtle.turnRight()
- while z > 1 do
- turtle.forward()
- z = z - z
- data()
- end
- running = "no"
- data()
- end
- function fuel()
- while turtle.getFuelLevel() < 200 do
- term.clear()
- term.setCursorPos(1,1)
- print("Refueling")
- print("Ensure slot 1 has coal more than 5 coal")
- sleep(5)
- turtle.refuel(5)
- end
- end
- function data()
- term.clear()
- term.setCursorPos(1,1)
- print("Running = ".. running)
- print("X = ".. x)
- print("Y = ".. y)
- print("Z = ".. z)
- print("fuel = ".. turtle.getFuelLevel())
- end
- while running == "yes" do
- data()
- fuel()
- if y < Y then
- if z < Z then
- if x < X then
- mineX()
- else
- if direction == "up" then
- turtle.turnRight()
- mineZ()
- turtle.turnRight()
- x = 1
- direction = "down"
- else
- turtle.turnLeft()
- mineZ()
- turtle.turnLeft()
- x = 1
- direction = "up"
- end
- end
- else
- if (z == Z) and (x < X) then
- mineX()
- else
- mineY()
- end
- end
- else
- if (y == Y) and (z < Z) and (x < X) then
- mineX()
- else
- if (y == Y) and (z < Z) and (x == X) then
- if direction == "up" then
- turtle.turnRight()
- mineZ()
- turtle.turnRight()
- x = 1
- direction = "down"
- else
- turtle.turnLeft()
- mineZ()
- turtle.turnLeft()
- x = 1
- direction = "up"
- end
- else
- if (y == Y) and (z == Z) and (x < X) then
- mineX()
- else
- finished()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement