Posted 04 March 2012 - 10:06 PM
So I am working on making the best diamond mine program out there (at least the best for my purposes). It will not be 100% automatic but it will strip mine for you and then you just have to dig out the ores.
How it works: Place torches in slot 9, run the program from where you want it to return to, at f=0 it will dump the resources there once you run it after the first cycle.
It will make the main strip for the mine, mark which sides to strip mine on and mines on the left side of that strip. Currently it is hardcoded for the most part and will only mine on the left. So if anyone would like to improve this program you are welcome to, thats why i'm posting this up here. Also i'm new to lua so i'm programming it with the functions i can figure out not always the easiest way.
Also this requires the magicTurtle API (because I don't feel like reinventing the wheel on a coord finding system).
Heres the code:
How it works: Place torches in slot 9, run the program from where you want it to return to, at f=0 it will dump the resources there once you run it after the first cycle.
It will make the main strip for the mine, mark which sides to strip mine on and mines on the left side of that strip. Currently it is hardcoded for the most part and will only mine on the left. So if anyone would like to improve this program you are welcome to, thats why i'm posting this up here. Also i'm new to lua so i'm programming it with the functions i can figure out not always the easiest way.
Also this requires the magicTurtle API (because I don't feel like reinventing the wheel on a coord finding system).
Heres the code:
Spoiler
local x=0
local y=0
local xcoord=516
local ycoord=524
local function strip()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.down()
turtle.down()
end
local function markStrip()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
end
local function mainBranch()
strip()
turtle.turnRight()
if turtle.detect() then
turtle.dig()
end
turtle.forward()
turtle.turnLeft()
strip()
if turtle.detect() then
turtle.dig()
end
turtle.forward()
xcoord=math.floor(xcoord-1)
turtle.turnLeft()
if turtle.detect() then
turtle.dig()
end
turtle.forward()
turtle.turnRight()
end
local function digg()
while y<7 do
y=y+1
turtle.dig()
turtle.up()
turtle.dig()
turtle.up()
turtle.dig()
turtle.down()
turtle.down()
if turtle.detect()==false then
turtle.forward()
ycoord=math.floor(ycoord+1)
end
end
end
local function torch()
turtle.turnRight()
turtle.turnRight()
turtle.select(9)
turtle.place()
turtle.turnRight()
turtle.turnRight()
end
local function start()
turtle.select(1)
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
turtle.select(5)
turtle.drop()
turtle.select(6)
turtle.drop()
turtle.select(7)
turtle.drop()
turtle.select(8)
turtle.drop()
turtle.select(1)
turtle.turnRight()
turtle.turnRight()
magicTurtle.setNorth()
turtle.forward()
ycoord=math.floor(ycoord-1)
turtle.turnLeft()
while turtle.detect()==false do
turtle.forward()
xcoord=math.floor(xcoord-1)
end
end
local function main()
start()
mainBranch()
mainBranch()
mainBranch()
markStrip()
while turtle.getItemSpace(6)>63 and turtle.getItemCount(9)>1 do
digg()
print(xcoord,ycoord)
y=0
torch()
end
turtle.turnRight()
turtle.turnRight()
magicTurtle.setNorth()
magicTurtle.setPos(xcoord,12,ycoord)
magicTurtle.goToPos(515,12,524,true)
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end