Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Automatic mining program that has turtles dig a 2x3 spur shaft to the left off of a main shaft until inventory is full. Turtle then exits the spur shaft until it hits the wall of the main shaft, heads towards a resupply chest, then empties its contents into a dump chest before heading back through the main shaft to start a new spur.
- --TODO
- --make it so turtles stop at each spur twice to mine
- --allow turtles to mine veins of ores
- --switch main from 2Wx6H to 1Wx2H
- --make function to check for torches in slot 16 and display error message if not
- --digs forward and repeats in case of gravel
- function gravel()
- while turtle.detect() do
- turtle.dig()
- end
- end
- --digs up and repeats in case of gravel
- function gravelUp()
- local i = 0
- while i < 10 do
- turtle.digUp()
- i = i + 1
- end
- end
- --places a torch 2 blocks high on the Right
- function placeTorch()
- turtle.select(16)
- turtle.placeUp()
- end
- --looks for fuel if low and refuels
- function getFuel()
- if turtle.getFuelLevel() < 90 then
- local i = 1
- while i < 16 do
- turtle.select(i)
- turtle.refuel()
- i = i + 1
- end
- end
- print("refueled")
- end
- --digs a 1Wx2H tunnel
- function spur()
- gravel()
- turtle.forward()
- gravelUp()
- end
- --digs a 2 wide by 3 tall tunnel
- function standard()
- gravel()
- turtle.forward()
- turtle.turnLeft()
- gravel()
- gravelUp()
- turtle.up()
- gravel()
- gravelUp()
- turtle.up()
- gravel()
- turtle.down()
- turtle.down()
- gravel()
- turtle.turnRight()
- print ("standard")
- end
- --drops all items in a given slot
- function dropStack()
- local s = 0
- while s < 64 do
- turtle.drop()
- s = s + 1
- end
- end
- --function to drop all items except slot in 16
- function dropEverything()
- local t = 1
- while t < 16 do
- turtle.select(t)
- dropStack()
- t = t + 1
- end
- print("everything dropped")
- end
- --turtle checks amount less 64 of torches it has and takes the remainder from supply chest
- function reSupply()
- local supply = 0
- supply = 64 - turtle.getItemCount(16)
- turtle.suck(supply)
- print(turtle.getItemCount(16))
- print("torches left")
- end
- -- returns the turtle back to base
- function returnToBase()
- print("returning to base")
- -- variable to allow turtle to travel back to original location
- local path = 0
- turtle.turnLeft()
- turtle.turnLeft()
- -- exits spur shaft
- repeat
- turtle.forward()
- until turtle.detect()
- turtle.turnRight()
- -- heads down main shaft to supply/dump chest. supply on bottom, dump on top
- repeat
- turtle.forward()
- path = path + 1
- until turtle.detect()
- reSupply()
- turtle.up()
- dropEverything()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- --heads back down main shaft
- while path > 0 do
- turtle.forward()
- path = path - 1
- end
- --makes main shaft 2 blocks longer
- local q = 0
- while q < 2 do
- standard()
- q = q + 1
- end
- turtle.turnLeft()
- end
- --checks if inventory is full and if true heads back to base
- function checkFull()
- local full = 0
- local g = 1
- while g < 16 do
- if turtle.getItemCount(g) > 0 then
- full = full + 1
- print(full)
- print("full")
- end
- g = g + 1
- end
- if full <= 15 then
- returnToBase()
- end
- end
- --main
- getFuel()
- while turtle.getFuelLevel() > 15 do
- local i = 0
- while i < 5 do
- print("i should dig")
- spur()
- i = i + 1
- end
- getFuel()
- placeTorch()
- checkFull()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement