Jump to content




[Lua][Error]


  • You cannot reply to this topic
7 replies to this topic

#1 IceCrasher

  • Members
  • 40 posts

Posted 30 September 2012 - 07:35 PM

Hi guys, I got the following error message, i can't find out the problem since 2 hours :)/> :

startup:4: attempt to cancatenate
string and nil


when i tipe in the shell "gps locate" it works

and here is my programm:


rednet.open("right")
x, y, z = gps.locate

print (x..", "..y..", "..z)

How can I save the gps coordinates in x, y and z and show me them by printing on the screen?

Thank you for helping

IceCrasher

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 September 2012 - 07:36 PM

You'll need the parentheses:

x, y, z = gps.locate()


#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 September 2012 - 07:38 PM

You need to call the gps.locate function, like this:
local x, y, z = gps.locate(1) -- it needs a timeout in seconds, you can change it to whatever you want
if x and y and z then -- check if it could get the position (when it times out the position is nil)
  print(x, ", ", y, ", ", z)
else
  print("Couldn't get position")
end


#4 IceCrasher

  • Members
  • 40 posts

Posted 30 September 2012 - 07:39 PM

okay, I did it an now i get the following error message:

gps:69: attempt to compare nil with
number

#5 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 September 2012 - 07:40 PM

You need to add the timeout parameter like I did.

#6 IceCrasher

  • Members
  • 40 posts

Posted 30 September 2012 - 07:43 PM

thank you so much xD It's working now *_*

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 September 2012 - 07:45 PM

View PostMysticT, on 30 September 2012 - 07:40 PM, said:

You need to add the timeout parameter like I did.

Oh, interesting. I guess I thought it worked like the rednet calls' timeout parameter. I suppose not.

#8 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 September 2012 - 07:47 PM

See this thread for more info.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users