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

distance between two computers

Started by jonteman98, 11 March 2013 - 10:53 PM
jonteman98 #1
Posted 11 March 2013 - 11:53 PM
how do i get the distance between two computers? they are on the same x and z coordinates so it´s only y i need to know.
theoriginalbit #2
Posted 11 March 2013 - 11:57 PM
you can use the GPS or Rednet systems for the easiest way

GPS requires some maths. but with GPS you need at least 4 computers with their position programmed and then they get the x,y,z coord.

Using Rednet this happens (its similar with 'modem_message' in CC1.5+)

local event, senderId, message, distanceSent = os.pullEvent('rednet_message')
JokerRH #3
Posted 12 March 2013 - 12:08 AM
GPS requires some maths. but with GPS you need at least 4 computers with their position programmed and then they get the x,y,z coord.

GPS sends a rednet ping and waits for the GPS hosts to send back a message, then calculates the position using trilateration. So if you use GPS to calculate the distance it is the same as if you send a message directly to the computer, as you mentioned too. That means it wouldn't make sense to use GPS. (unless your computers are too far away from each other)
theoriginalbit #4
Posted 12 March 2013 - 12:10 AM
(unless your computers are too far away from each other)
And that is why I included that method as well.
jonteman98 #5
Posted 12 March 2013 - 12:37 AM
thanks