Posted 27 February 2013 - 04:50 PM
A simple quarry program.
[media]http://www.youtube.com/watch?v=8BmEMSAKuCI[/media]
[media]http://www.youtube.com/watch?v=8BmEMSAKuCI[/media]
args = {...}
if #args ~= 3 then
return
end
x,y,z = args[1], args[2], args[3]
xt = 0
yt = 1
zt = 0
mt = 0
rotate = 0
x = tonumber(x)
y = tonumber(y)
z = tonumber(z)
while true do
if zt == z then
return
end
while xt < x do
if turtle.forward() == true then
xt = xt + 1
else
if zt == 0 then
while turtle.detect() == true do
turtle.dig()
sleep(1)
end
else
turtle.dig()
end
end
end
mt = mt + 1
if xt == x and rotate == 0 and yt < y then
turtle.turnRight()
if zt == 0 then
while turtle.detect() == true do
turtle.dig()
sleep(1)
end
else
turtle.dig()
end
turtle.forward()
turtle.turnRight()
rotate = 1
yt = yt + 1
xt = 1
end
if xt == x and rotate == 1 and yt < y then
turtle.turnLeft()
if zt == 1 then
while turtle.detect() == true do
turtle.dig()
sleep(1)
end
else
turtle.dig()
end
turtle.forward()
turtle.turnLeft()
rotate = 0
xt = 1
yt = yt + 1
end
if mt == y and rotate == 0 and zt < z then
if zt ~= z then
turtle.digDown()
turtle.down()
else
return
end
turtle.turnLeft()
turtle.turnLeft()
yt = 1
mt = 0
zt = zt + 1
xt = 1
rotate = 0
end
if mt == y and rotate == 1 and zt < z then
reset = 1
while reset < x do
turtle.back()
reset = reset + 1
end
if zt ~= z then
turtle.digDown()
turtle.down()
else
return
end
yt = 1
mt = 0
zt = zt + 1
xt = 1
rotate = 0
end
shell.run('clear')
print(rotate)
print(mt)
os.queueEvent("Crash")
os.pullEvent()
end