Posted 15 April 2013 - 09:23 AM
I have been working on a automatic tree Farming program. It is supposed to be fully integrated with gps so that it can find its place in the code from startup. It was working well, until I added the startup program. Once I did, it started messing up. I got rid of the startup, then closed and reopened minecraft. And when I try it now it errors : treeFarm:38: attempt to compsre __lt on nil and nil
I don't remember changing something in the code, but I obviously did. I can't figure out what I did, however. I have below the function that errors (also 2 others that it uses inside of it). It is the orient function. upon startup, it is supposed to check its coords, move, and based on the difference, figure out what direction it is facing.
The full code is here: http://pastebin.com/9MTQE1xn
Note: There is probably some "junk" code or something that won't work in the full code, because I was doing some tuning up when this happened, so not all of the code has been tested to work.
I don't remember changing something in the code, but I obviously did. I can't figure out what I did, however. I have below the function that errors (also 2 others that it uses inside of it). It is the orient function. upon startup, it is supposed to check its coords, move, and based on the difference, figure out what direction it is facing.
function forward()
while not turtle.forward() do
turtle.dig()
end
end
function getPos()
x,y,z = gps.locate()
end
function orient()
getPos()
xx = x
zz = z
forward()
getPos()
if zz > z then -- line 38
direction = "north"
elseif zz < z then
direction = "south"
elseif xx > x then
direction = "west"
elseif xx < x then
direction = "east"
end
print(direction)
os.sleep(1)
turtle.back()
end
The full code is here: http://pastebin.com/9MTQE1xn
Note: There is probably some "junk" code or something that won't work in the full code, because I was doing some tuning up when this happened, so not all of the code has been tested to work.