Posted 01 April 2013 - 04:59 AM
I'm getting an error on line 3about an end expected. Here is my code
function mineup()
until turtle.detectUp() == false then
turtle.digUp()
turtle.up()
else
until turtle.detectDown() == true then
turtle.down()
end
end
end
function ddf()
if turtle.detect() == true then
turtle.dig()
turtle.forward()
else
turtle.forward()
end
end
function checkfuel()
if turtle.getFuelLevel <= 10 then
turtle.select(1)
turtle.refuel()
end
end
print("Hello. Welcome to the Cheesety210 Tree cutting program")
print("Please put your fuel in the first slot.")
turtle.turnRight()
turtle.turnRight()
turtle.turnRight()
turtle.turnRight()
clear
print("I, your turtle, should be placed at the bottom of a tree")
print("right next to the tree. A diagram is below.")
print(" [ ] = A log, and T is the turtle")
print("[ ] [ ] ")
print("[ ] [ ] ")
print(" T ")
print(" What is the width/length of the tree? In the example above it's 2.")
local length = read()
if length == 1 then
checkfuel()
ddf()
mineup()
end
if length == 2 then
checkfuel()
ddf()
mineup()
checkfuel()
ddf()
mineup()
checkfuel()
turtle.turnRight()
ddf()
mineup()
checkfuel()
turtle.turnRight()
ddf()
mineup()
checkfuel()
turtle.forward()
end
if length == 3 then
ddf()
mineup()
checkfuel()
ddf()
mineup()
checkfuel()
ddf()
mineup()
checkfuel()
turtle.turnRight()
ddf()
mineup()
checkfuel()
turtle.turnRight()
ddf()
mineup()
checkfuel()
ddf()
mineup()
checkfuel()
turtle.turnLeft()
ddf()
mineup()
checkfuel()
turtle.turnLeft()
ddf()
mineup()
checkfuel()
ddf()
mineup()
end
print("I am done with this tree!")
I'm not exactly sure how to use until's in a function.