This is my latest project (projects?). I wanted to utilize dan200's recent additions to ComputerCraft, most notably the turtles' ability to place items in chests. The program pack comes with three modules, and two flavors of mineshaft. The "mine" program is the best I've ever made. You choose the x,y, AND z values to give greater flexibility/freedom. The turtle places torches in all three programs to keep the mines clear of zombies and skeletons and *BLAM(s)*
A brief explanation of all is available, as well as instructions, and most importantly: CODES!
Spoiler
"vertshaft"–Digs straight down, placing ladders, cobble and torches as necessary on the way back up.
[attachment=407:vertshaft.JPG]
Descending a vertshaft ^ ^ ^
"stairshaft"
–Makes the familiar staircase-shaft we all know and love. Lights the shaft as it goes, and mines an extra head-room block so players can add stairs/rails.
[attachment=408:stairshaft.JPG]
A stairshaft, standing next to a torch.
"mine"
–The real reason I posted this. You set the width, then the length, and lastly, height. The turtle drops the items in a chest (or the ground, if you don't provide one) and returns to mining. It lights the mine as it goes.
[attachment=409:mine.JPG]
An 11 * 10 * 5 mine, depth of 20 blocks. Complete with 1 torch.
These programs tell you what to give it and where to put them.
Spoiler
The more important question is: where do you put it? The program is pretty simple to grasp, and once you use it, you will love it."vertshaft"
–The program will ask you how deep you want to make your mine. Type in a positive number, and provide ladders, torches, coal, and cobble where it tells you to put them. Then press any character key, like "q."
"stairshaft"
–Again, it asks you how deep you want the mine, and requests coal, torches, and cobble in their respective slots. Then you press any character key, like "q."
"mine"
–This requires a little more explanation. Watch the turtle until it completes the second row. Once it does, look at the way it mined. The turtle probably mined a few to many blocks in the first row, but it corrects itself on the second row. On the same wall as the entrance, place a chest in the wall corner and mirror on the other side.
(see mine.jpg for visual aid, under "What does it do?")
The turtle does place torches as it goes, but it doesn't start doing that for five rows, which can take a while. I recommend lighting it yourself at this stage, and that's it. You'll be raking in the diamonds. Or build yourself a castle with the massive, massive amount of cobble you will amass.
Spoiler
"vertshaft"Spoiler
glow = 0function moveForward()
repeat
turtle.dig()
until turtle.forward()
end
function mineUp()
repeat
turtle.digUp()
until turtle.up()
end
function refuel()
if turtle.getFuelLevel() <= 5 then
turtle.select(16)
turtle.refuel(1)
end
end
function selectLadder()
turtle.select(15)
if turtle.getItemCount(15) == 1 then
turtle.select(1)
while not turtle.compareTo(15) do
for i = 1,12 do
turtle.select(i)
end
end
end
end
function selectDirt()
turtle.select(14)
if turtle.getItemCount(14) == 1 then
turtle.select(1)
while not turtle.compareTo(14) do
for i = 1,12 do
turtle.select(i)
end
end
end
end
function placeLadder()
selectLadder()
if not turtle.place() then
selectDirt()
moveForward()
turtle.place()
turtle.back()
selectLadder()
if not turtle.place() then
return false
end
end
end
function torch()
if glow == 6 then
turtle.digDown()
turtle.select(13)
turtle.placeDown()
glow = glow-glow
end
end
print "Place ladder instance in slot 15, Fuel in 16, and dirt/stone in 14. Torches go in 13."
print "When only one ladder or filler is in their slots, program will look elsewhere."
print "How deep do you want to mine? (z)"
z = io.read()
z = tonumber(z)
print "Press any key to run."
os.pullEvent("char")
for i = 1,z do
turtle.digDown()
turtle.down()
refuel()
end
moveForward()
refuel()
turtle.turnLeft()
turtle.turnLeft()
for i = 1,z do
if not placeLadder() then
–break
end
torch()
selectDirt()
turtle.placeDown()
mineUp()
refuel()
glow = glow+1
end
"stairshaft"
Spoiler
glow = 0function moveForward()
repeat
turtle.dig()
until turtle.forward()
end
function refuel()
if turtle.getFuelLevel() <= 5 then
turtle.select(16)
turtle.refuel(1)
end
end
function seal()
if not turtle.detectDown() then
turtle.select(15)
turtle.placeDown()
end
end
function mine()
turtle.digDown()
turtle.digUp()
turtle.up()
turtle.digUp()
turtle.down()
turtle.down()
end
function torch()
if glow == 6 then
turtle.turnRight()
turtle.dig()
turtle.select(14)
turtle.place()
turtle.turnLeft()
glow = glow-glow
end
end
print "Fuel in slot 16, dirt/stone in 15, and torches in 14."
print "How deep do you want to go? This isn't about length, just depth."
z = io.read()
z = tonumber(z)
print "Press any key to run."
os.pullEvent("char")
for i = 1,z do
refuel()
mine()
seal()
moveForward()
glow = glow+1
torch()
end
"mine"
Spoiler
–declaring variablesturtdir = 0
glowy = 0
glowx = 0
print "This will mine a predefined pattern of blocks. Use after vertshaft or stairshaft."
print "All values are positive integers."
print "Fuel in slot 16, torches in slot 15."
print "How wide is this mine?(x) !MUST BE AN ODD NUMBER!"
x = io.read()
x = tonumber(x)
print "How far forward? (y)"
y = io.read()
y = tonumber(y)
y = y-1
print "How high? (z)"
z = io.read()
z = tonumber(z)
z = z-1
print "Press any key to run."
os.pullEvent("char")
– origins
sxo = x/2
sxo = math.ceil(sxo)
syo = y/2
syo = math.ceil(syo)
– sxo and syo is used to find the turtle's start point. It is crucial that x be odd for this to work right.
xo = 0
yo = 0
zo = 0
setup = sxo/2
setup = math.ceil(setup)
– declaring functions
function checkFuel()
if turtle.getFuelLevel() <= z*2+2 then
turtle.select(16)
turtle.refuel(1)
end
end
function moveForward()
checkFuel()
repeat
turtle.dig()
until turtle.forward()
end
function mineUp()
if zo == 0 then
for i = 1,z do
checkFuel()
repeat
turtle.digUp()
until turtle.up()
zo = zo+1
end
end
end
function mineDown()
if zo ~= 0 then
repeat
checkFuel()
repeat
turtle.digDown()
until turtle.down()
zo = zo-1
until zo == 0
end
end
function checka()
if turtle.getItemCount(14) >= 1 then
turtle.turnLeft()
for i = 1,yo do
moveForward()
checkFuel()
end
for i = 1,14 do
turtle.select(i)
turtle.drop()
end
turtle.turnLeft()
turtle.turnLeft()
for i = 1,yo do
moveForward()
checkFuel()
end
turtle.turnLeft()
turtle.select(1)
end
end
function checkb()
if turtle.getItemCount(14) >= 1 then
turtle.turnRight()
for i = 1,yo do
moveForward()
checkFuel()
end
for i = 1,14 do
turtle.select(i)
turtle.drop()
end
turtle.turnLeft()
turtle.turnLeft()
for i = 1,yo do
moveForward()
checkFuel()
end
turtle.turnRight()
turtle.select(1)
end
end
function torch()
if glowx > 6 or glowx < 0 then
glowx = 0
end
if glowy == 5 and glowx == 6 then
turtle.turnLeft()
turtle.turnLeft()
turtle.select(15)
turtle.place()
turtle.turnRight()
turtle.turnRight()
glowx = glowx-glowx
end
end
– setting up to align
turtle.turnLeft()
for i = 1,setup do
mineUp()
moveForward()
mineDown()
moveForward()
end
turtle.turnLeft()
turtle.turnLeft()
mineUp()
mineDown()
for i = 1,setup do
moveForward()
end
for i = 1,setup do
moveForward()
mineUp()
moveForward()
mineDown()
end
– and finally, on line 147, we have reached the main loop.
for i = 1,syo do
turtdir = 1
checkb()
turtle.turnLeft()
moveForward()
yo = yo+1
if glowy == 6 then
glowy = glowy-glowy
end
glowy = glowy+1
turtle.turnLeft()
for a = 1,sxo-1 do
mineUp()
moveForward()
glowx = glowx+1
xo = xo+1
mineDown()
moveForward()
xo = xo+1
glowx = glowx+1
torch()
end
turtdir = 2
checka()
turtle.turnRight()
mineUp()
mineDown()
moveForward()
yo = yo+1
if glowy == 6 then
glowy = glowy-glowy
end
glowy = glowy+1
turtle.turnRight()
for b = 1,sxo-1 do
mineUp()
moveForward()
xo = xo-1
glowx = glowx-1
mineDown()
moveForward()
xo = xo-1
glowx = glowx-1
torch()
end
mineUp()
mineDown()
end
if turtdir == 1 then
turtle.turnLeft()
for i = 1,yo do
moveForward()
checkFuel()
end
for i = 1,16 do
turtle.select(i)
turtle.drop()
end
end
if turtdir == 2 then
turtle.turnRight()
for i = 1,yo do
moveForward()
checkFuel()
end
for i = 1,16 do
turtle.select(i)
turtle.drop()
end
end
Spoiler
Bugs: :P/>/>"mine"
Do not enter an even number like "2" as "x," weird things happen.
Will probably mine a few too many blocks in the first row. Unsure how to fix. If it mines WAY too many, report it, in addition to the variables you told it.
No more known bugs, report any you find, and I will try to fix them, or at least warn other people.
Reccomended:
Don't enter ridiculous values in the turtle that I may not have prepared for. The turtle will still spill excess, and it only checks after every row, not during. Try to keep every row (x * z) under 100 blocks to minimize that risk. 25 x, 4 z, and 1,000,000 y works fine. (until it leaves the chunk limit) (!Statement Not Tested!)
I'm out of ideas, by the way. If someone thinks of a good turtle program that they want me to try making, tell me. Bugs? Tell me all about it. Happy? I'd love to hear it. I hope you enjoy this program as much as I enjoyed making it for you. :D/>/>
–Lettuce