Jump to content




Rednet + GPS + Tables


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

#1 joe500

  • New Members
  • 1 posts

Posted 19 May 2013 - 12:06 AM

Hi guys,

I try to set up a decent GPS system to navigate alle my stuff with it. The core system is up and running, and i can locate all my positions. The only problem that I've is that I cant send my coordinates over rednet. For example I wrote some code:

rednet.open("top", 1)
x, y, z = gps.locate(3)

vec={ value1=x, value2=y, value3=z}
svec=textutils.serialize(vec)
rednet.send(1, svec)

Now on the receiver side:

  
rednet.open("top", 1)

id, msg, dist=rednet.receive()
vec=textutils.unserialize(msg)
x=vec.value1
y=vec.value2
z=vec.value3

I cant access the transmited values 1-3 It just crashes with attempt to call nil...

Pls help me I'm getting crazy about this :D

PS:I've checked svec and it was created correct I think the problem is in the gps.locate function, cause if I hardcode the values 1-3 and then transmit the table everything works like a charm.

Edited by Lyqyd, 19 May 2013 - 11:20 PM.
code tags; formatting.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 19 May 2013 - 11:19 PM

Split into new topic.

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 May 2013 - 12:10 AM

add in two print statements, and lets see whats going on...

in the sender add this just before you make the vec table
print('X: '..tostring(x)..' Y: '..tostring(y)..' Z: '..tostring(z))
and add this to the receiver
print(msg)
what do they say?

Also just an FYI, rednet.open only accepts 1 parameter, the side, so the 1 in both those function calls are not needed.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users