Posted 04 September 2012 - 03:50 PM
Hi,
I've been trying to find a good quarry program for a while and yesterday i gave up and made one myself.
You can change the width, length and height.
pastebin:
code:
mx = 50
my = 50
mz = 10
– Don't change anything bellow this line
x = 0
y = 0
z = 0
cx = 0
cy = 0
cz = 0
posy = 0
posx = 0
function f()
if turtle.forward() == false then
repeat
turtle.dig()
sleep(0.25)
until turtle.forward() == true
end
end
function d()
if turtle.down() == false then
repeat
turtle.digDown()
sleep(0.25)
until turtle.down() == true
end
end
function u()
if turtle.up() == false then
repeat
turtle.digUp()
sleep(0.25)
until turtle.up() == true
end
end
function check()
for i = 1,8 do
if turtle.getItemCount(i) == 0 then
return true
end
end
end
function dropall()
for dropSlot = 1,9 do
turtle.select(dropSlot)
turtle.drop()
end
turtle.select(1)
turtle.turnRight()
turtle.turnRight()
end
function down()
while cz < mz do
d()
cz = cz+1
end
end
function up()
while cz > z do
u()
cz = cz-1
end
end
function bdig()
if cz == z and cx == x then
goback()
dropall()
else
up()
goback()
dropall()
end
end
function goback()
posy = cy
posx = cx + 1
print("y - ",posy)
print("x - ",posx)
turtle.turnLeft()
while cx > x do
f()
cx = cx - 1
end
turtle.turnLeft()
while cy > y do
f()
cy = cy - 1
end
end
function udig()
while check() and cy < my do
turtle.digUp()
down()
up()
f()
cy = cy+1
end
bdig()
end
while true do
if posx == x then
while cy < posy do
f()
cy = cy + 1
end
udig()
elseif posx < mx and posy == my then
turtle.turnRight()
while cx < posx do
f()
cx = cx + 1
end
turtle.turnLeft()
udig()
elseif posx < mx and posy ~= my then
turtle.turnRight()
while cx < posx - 1 do
f()
cx = cx + 1
end
turtle.turnLeft()
while cy < posy do
f()
cy = cy + 1
end
udig()
elseif posy == my and posx == mx then
print("Complete")
break
end
end
The turtle will dig until area is clear.
When full the turtle will return to start and drop all items on the block behind it, then go back to the spot and keep digging.
I use a transposer behind the turtle connected to a chest and the turtle will drop all items in the chest, i don't have 1.4 yet, so i don't have the fuel option and putting items directly into chests.
I'm not very good at lua, so please feel free to suggest any changes to the code.
enjoy =P
PS: anyone know how to save variables in a file or something so it keeps the coords after reboot?
I've been trying to find a good quarry program for a while and yesterday i gave up and made one myself.
You can change the width, length and height.
pastebin:
Spoiler
http://pastebin.com/G0aRHRruSpoiler
– change mx for width, my for length and mz for height, the turtle will dig down and to the rightmx = 50
my = 50
mz = 10
– Don't change anything bellow this line
x = 0
y = 0
z = 0
cx = 0
cy = 0
cz = 0
posy = 0
posx = 0
function f()
if turtle.forward() == false then
repeat
turtle.dig()
sleep(0.25)
until turtle.forward() == true
end
end
function d()
if turtle.down() == false then
repeat
turtle.digDown()
sleep(0.25)
until turtle.down() == true
end
end
function u()
if turtle.up() == false then
repeat
turtle.digUp()
sleep(0.25)
until turtle.up() == true
end
end
function check()
for i = 1,8 do
if turtle.getItemCount(i) == 0 then
return true
end
end
end
function dropall()
for dropSlot = 1,9 do
turtle.select(dropSlot)
turtle.drop()
end
turtle.select(1)
turtle.turnRight()
turtle.turnRight()
end
function down()
while cz < mz do
d()
cz = cz+1
end
end
function up()
while cz > z do
u()
cz = cz-1
end
end
function bdig()
if cz == z and cx == x then
goback()
dropall()
else
up()
goback()
dropall()
end
end
function goback()
posy = cy
posx = cx + 1
print("y - ",posy)
print("x - ",posx)
turtle.turnLeft()
while cx > x do
f()
cx = cx - 1
end
turtle.turnLeft()
while cy > y do
f()
cy = cy - 1
end
end
function udig()
while check() and cy < my do
turtle.digUp()
down()
up()
f()
cy = cy+1
end
bdig()
end
while true do
if posx == x then
while cy < posy do
f()
cy = cy + 1
end
udig()
elseif posx < mx and posy == my then
turtle.turnRight()
while cx < posx do
f()
cx = cx + 1
end
turtle.turnLeft()
udig()
elseif posx < mx and posy ~= my then
turtle.turnRight()
while cx < posx - 1 do
f()
cx = cx + 1
end
turtle.turnLeft()
while cy < posy do
f()
cy = cy + 1
end
udig()
elseif posy == my and posx == mx then
print("Complete")
break
end
end
The turtle will dig until area is clear.
When full the turtle will return to start and drop all items on the block behind it, then go back to the spot and keep digging.
I use a transposer behind the turtle connected to a chest and the turtle will drop all items in the chest, i don't have 1.4 yet, so i don't have the fuel option and putting items directly into chests.
I'm not very good at lua, so please feel free to suggest any changes to the code.
enjoy =P
PS: anyone know how to save variables in a file or something so it keeps the coords after reboot?