2 posts
Posted 08 September 2012 - 09:22 PM
Anyone knows what this error means?
mine:33: attempt to compare __lt on nil and nil
function that gets the error
"if x > nx then" is line 33 in my code
Spoiler
–Detect which direction turtle is facing
function getF()
local fac = "0"
local x,y,z = gps.locate(1,false)
refuel()
turtle.forward(1)
local nx,ny,nz = gps.locate(1,false)
turtle.back(1)
if x > nx then
fac = "1" –East
elseif x < nx then
fac = "3" –West
elseif z > nz then
fac = "2" –South
elseif z < nz then
fac = "0" –North
else
print("Position didn't change. Something blocking turtle?")
fac = "Error"
end
return fac
endMy entire code is here:
http://pastebin.com/aWwfcRSr
10 posts
Posted 08 September 2012 - 09:41 PM
I know what's wrong, the gps api for gps.locate is returning nil because it couldn't get replies from gps host computers because you forgot to turn on a rednet modem.
2 posts
Posted 08 September 2012 - 10:11 PM
Yeah just figured it out.
Wireless transmitter on the turtle was off.
Adding rednet.open("right") fixed it.
But for some reason turtle.dig() isn't doing anything.
Can a normal turtle not dig dirt?
Edit: Mining Turtle seems to be working the way I want it.
Except I put it bit too close to my house now, lol.
10 posts
Posted 08 September 2012 - 10:30 PM
if it's a mining wireless turtle it can, but if it's a regular wireless turtle(with no tool on it), it can't dig at all.
5 posts
Posted 08 October 2012 - 11:04 PM
Guys i'm getting the same error. with line 64 it's: if xTarget > xCoord then
look("west")
PS: I'm not using a wireless one.
105 posts
Posted 09 October 2012 - 12:57 AM
Your variables are nil. Make sure they're actually being assigned a value, and in scope if they're locals.
Can't provide much more help without more code.
5 posts
Posted 09 October 2012 - 03:17 PM
What do you mean by "nil" sorry, kinda new to computercraft.
105 posts
Posted 09 October 2012 - 03:26 PM
From the lua manual:
Nil is the type of the value nil, whose main property is to be different from any other value; usually it represents the absence of a useful value.
5 posts
Posted 09 October 2012 - 03:54 PM
Here's the code please let me know if you know what it is.
http://pastebin.com/EFFvY6vM
105 posts
Posted 09 October 2012 - 04:18 PM
xTarget and zTarget haven't been declared at that point in the code.
Also you have at line 37: function.moveUp() should be function moveup()
And you have an infinite loop in moveDown()
5 posts
Posted 09 October 2012 - 04:26 PM
Fixed all the problems except the __lt, i meant line 66 (64 in computercraft).
5 posts
Posted 09 October 2012 - 06:49 PM
Can you please help me?