Posted 07 July 2012 - 12:22 AM
Hey, I'm getting an Unexpected Symbol on line 72 (commented), any help fixing would be greatly appreciated.
Also, how do I condense my TarIn function so that the coords can be entered on one line?
Thanks very much.
P.s. Very sorry, only just remembered that I should have labelled this [Lua][Error]!
Also, how do I condense my TarIn function so that the coords can be entered on one line?
Thanks very much.
function CalLoc()
x, y, z = gps.locate(1)
if x == nil or y == nil or z == nil then
error("Failed to get coordinates for initial location, check GPS Hosts")
else
print ("Current coordinates:")
print ("x: "..x)
print ("y: "..y)
print ("z: "..z)
end
end
function CalFac()
turtle.forward()
curx, cury, curz = gps.locate(1)
if curx == nil or cury == nil or curz == nil then
error("Failed to get coordinates for orientation, check GPS Hosts")
else
if x == curx and y == cury then
error("Failed to move, please check obstacles")
else
if curx > x then
fac = 1
print ("East "..fac)
else
if curx < x then
fac = 3
print ("West "..fac)
else
if cury > y then
fac = 2
print ("South "..fac)
else
if cury < y then
fac = 4
print ("North "..fac)
else
error("Failed to get facing")
end
end
end
end
end
end
end
function TarIn()
print("Enter target coordinates")
write("X: ")
tarx = read()
write("Y: ")
tary = read()
write("Z: ")
tarz = read()
print("Coordinates confirmed as "..tarx..", "..tary..", "..tarz)
end
function flytoZ()
if curz < tarz then
repeat
turtle.up()
curz=curz+1 --Y U SO BUGGY?
until curz >= tarz
else
if curz > tarz then
repeat
turtle.down()
curz=curz-1
until curz <= tarz
else
end
end
end
CalLoc()
CalFac()
TarIn()
flytoZ()
print ("Finished flight")
P.s. Very sorry, only just remembered that I should have labelled this [Lua][Error]!
Edited on 06 July 2012 - 10:25 PM