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

Rednet + GPS + Tables

Started by joe500, 18 May 2013 - 11:06 PM
joe500 #1
Posted 19 May 2013 - 01: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 #2
Posted 20 May 2013 - 12:19 AM
Split into new topic.
theoriginalbit #3
Posted 20 May 2013 - 01: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.