3 posts
Location
France
Posted 04 April 2014 - 11:29 PM
I am actually using Computercraft 1.61
I tried to use rednet.receive() to get the distance between a computer and a PDA. The function doesn't return it.
In my test world I placed two computers with wireless modems and tried with the LUA prompt
The third value returned by rednet.receive() sould be a number for the distance or a string if a protocol is specified.
It works fine with a protocol, however if not specified nil is returned instead of a number.
3790 posts
Location
Lincoln, Nebraska
Posted 04 April 2014 - 11:30 PM
We've just updated ComputerCraft as you posted this. Try the new version available now, and let us know if you are still having the same issue.
http://www.computercraft.info/
7508 posts
Location
Australia
Posted 04 April 2014 - 11:46 PM
distance is no longer returned in the new ComptuerCraft versions (1.6 and above), instead it has been replaced by the protocol the message was sent over (if it was sent over one).
Relevant line in Rednet:
os.queueEvent( "rednet_message", nReplyChannel, tMessage.message, tMessage.sProtocol )
7083 posts
Location
Tasmania (AU)
Posted 05 April 2014 - 01:36 AM
Part of the reason for this is that a new "repeat" script has been included, which basically causes a modem-equipped system to sit and wait for incoming messages, which it'll automatically pass on (making it easier to extend the range of Rednet networks).
A side effect of this is that it becomes difficult (if not impossible) to accurately determine the distance between the original sending system and the intended recipient of a given message… So that data is stripped from the underlying modem_message events that the Rednet API uses to function.
Interacting with your modems
directly still allows access to the desired distance value. This is how the built-in GPS script continues to function.
524 posts
Location
Cambridge, England
Posted 05 April 2014 - 07:27 PM
Not a bug. This feature was removed as, due to the addition of repeaters, a rednet message now no longer represents a single point-to-point communication, so there's no way to calculate the straight-line distance from the origin to the receiver. The distance is still exposed by the modem_message event (which always represents a point-to-point communication), or you could calculate your own distances by taking the difference of gps.locate() calls at either end.