Posted 23 June 2012 - 10:21 PM
I spent a while writing a program for a mining turtle and when I was finally done, i started it, it printed the questions accepted my answers and then the turtle shutdown without doing anything. what am I doing wrong?
code:
while side ~= "right" and side ~= "left" do
print("which side?")
side = read()
end
while height ~= "top" and height ~= "middle" and height ~= "bottom" do
print("what height?")
height = read()
end
function forward()
while turtle.forward() ~= true do
end
end
function back()
while turtle.back() ~= true do
end
end
function dig()
a = 0
while turtle.dig() == true and a<5 do
sleep(.8)
a = a+1
end
end
function digUp()
a = 0
while turtle.digUp() == true and a < 5 do
sleep(.8)
a = a+1
end
end
function dig3()
dig()
forward()
digUp()
turtle.digDown()
end
if height == "top" then
while turtle.down ~= true do
end
end
if height == "bottom" then
while turtle.up ~= true do
end
end
if side == "left" then
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
while turtle.itemCount( 9 ) < 1 do
dig3()
turtle.turnRight()
dig3()
turtle.turnLeft()
if turtle.compare() == false then
dig3()
turtle.back()
turtle.place()
end
turtle.turnLeft()
forward()
turtle.turnRight()
dig3()
turtle.turnLeft()
dig3()
turtle.turnLeft()
dig3()
turtle.turnRight()
dig3()
turtle.turnRight()
dig3()
if turtle.compare() == false then
dig3()
turtle.back()
turtle.place()
end
turtle.turnRight()
forward()
turtle.turnLeft()
forward()
dig3()
turtle.turnRight()
dig3()
end
code:
while side ~= "right" and side ~= "left" do
print("which side?")
side = read()
end
while height ~= "top" and height ~= "middle" and height ~= "bottom" do
print("what height?")
height = read()
end
function forward()
while turtle.forward() ~= true do
end
end
function back()
while turtle.back() ~= true do
end
end
function dig()
a = 0
while turtle.dig() == true and a<5 do
sleep(.8)
a = a+1
end
end
function digUp()
a = 0
while turtle.digUp() == true and a < 5 do
sleep(.8)
a = a+1
end
end
function dig3()
dig()
forward()
digUp()
turtle.digDown()
end
if height == "top" then
while turtle.down ~= true do
end
end
if height == "bottom" then
while turtle.up ~= true do
end
end
if side == "left" then
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
while turtle.itemCount( 9 ) < 1 do
dig3()
turtle.turnRight()
dig3()
turtle.turnLeft()
if turtle.compare() == false then
dig3()
turtle.back()
turtle.place()
end
turtle.turnLeft()
forward()
turtle.turnRight()
dig3()
turtle.turnLeft()
dig3()
turtle.turnLeft()
dig3()
turtle.turnRight()
dig3()
turtle.turnRight()
dig3()
if turtle.compare() == false then
dig3()
turtle.back()
turtle.place()
end
turtle.turnRight()
forward()
turtle.turnLeft()
forward()
dig3()
turtle.turnRight()
dig3()
end