Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- area = 20
- function moveForward()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function moveUp()
- while not turtle.up() do
- turtle.digUp()
- currY = currY + 1
- end
- end
- --#### COMPARE UP ####
- function compareUp()
- turtle.select(1)
- turtle.compareUp()
- if turtle.compareUp() == true then
- print("Stone")
- else
- turtle.select(2)
- turtle.compareUp()
- if turtle.compareUp() == true then
- print("Gravel")
- else
- turtle.select(3)
- turtle.compareUp()
- if turtle.compareUp() == true then
- print("Marble")
- else
- turtle.select(4)
- turtle.compareUp()
- if turtle.compareUp() == true then
- print("Dirt")
- else
- turtle.digUp()
- print("Valuable found")
- end
- end
- end
- end
- end
- --#### COMPARE DOWN ####
- function compareDown()
- turtle.select(1)
- turtle.compareDown()
- if turtle.compareDown() == true then
- print("Stone")
- else
- turtle.select(2)
- turtle.compareDown()
- if turtle.compareDown() == true then
- print("Gravel")
- else
- turtle.select(3)
- turtle.compareDown()
- if turtle.compareDown() == true then
- print("Marble")
- else
- turtle.select(4)
- turtle.compareDown()
- if turtle.compareDown() == true then
- print("Dirt")
- else
- turtle.digDown()
- print("Valuable found")
- end
- end
- end
- end
- end
- --#### DROP OFF ####
- function dropOff()
- turtle.dig()
- turtle.select(16)
- turtle.place()
- for i = 5, 15 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(16)
- turtle.dig()
- end
- --#### MINE ROW ####
- function mineRow()
- for i = 1, area do
- moveForward()
- compareUp()
- compareDown()
- end
- dropOff()
- end
- --#### MINE 10x10 ###
- function mineSquare()
- for i = 1, area/2 do
- mineRow()
- turtle.turnRight()
- moveForward()
- turtle.turnRight()
- mineRow()
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- end
- turtle.turnLeft()
- for i = 1, area do
- moveForward()
- end
- turtle.turnRight()
- for i = 1,3 do
- moveUp()
- currY = currY + 1
- writeYLevel()
- end
- end
- -- #### MINE SEVERAL ROWS ####
- function mine()
- layers = math.floor(yStart / 4)
- for i = 1, layers do
- mineSquare()
- end
- end
- --#### TO BEDROCK ####
- function toBedrock()
- mineStart = yStart - 6
- currY = yStart
- for i = 1, mineStart do
- turtle.digDown()
- turtle.down()
- currY = currY - 1
- end
- writeYLevel()
- end
- -- #### RETURN TO SURFACE ####
- function goUp()
- for i = 1, yStart - currY do
- moveUp()
- currY = currY +1
- writeYLevel()
- end
- end
- -- ## WRITE FILE ##
- function writeStartLevel()
- handle = fs.open("startLevel", "w")
- handle.write(yStart)
- handle.close()
- end
- function writeYLevel()
- handle = fs.open("yLevel", "w")
- handle.write(currY)
- handle.close()
- end
- --#### LOOP ####
- print("What is my Y level?")
- yStart = io.read()
- writeStartLevel()
- print("I will mine a "..area.."x"..area.." area")
- toBedrock()
- mine()
- goUp()
- print("finished")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement