This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
redconfusion's profile picture

trouble with dig turtle program

Started by redconfusion, 08 September 2012 - 07:22 PM
redconfusion #1
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
end

My entire code is here:
http://pastebin.com/aWwfcRSr
WildCard65 #2
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.
redconfusion #3
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.
WildCard65 #4
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.
zinixiz #5
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.
Fatal_Exception #6
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.
zinixiz #7
Posted 09 October 2012 - 03:17 PM
What do you mean by "nil" sorry, kinda new to computercraft.
Fatal_Exception #8
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.
zinixiz #9
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
Fatal_Exception #10
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()
zinixiz #11
Posted 09 October 2012 - 04:26 PM
Fixed all the problems except the __lt, i meant line 66 (64 in computercraft).
zinixiz #12
Posted 09 October 2012 - 06:49 PM
Can you please help me?