Difference between revisions of "Gps (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(gps api does not triangulate, it trilaterates. even the function in the file itself is called "trilaterate". also 4 known points are needed to get a precise location 100% of the time. 3 can work, but almost always results in a nil return value)
m
Line 3: Line 3:
 
It broadcasts a PING message over [[Rednet_(API)|rednet]] and wait for responses. In order for this system to work, there must be at least 4 computers used as gps ''hosts'' which will respond and allow [https://en.wikipedia.org/wiki/Trilateration trilateration]. You can set up hosts using the [[Gps (program)|gps program]].
 
It broadcasts a PING message over [[Rednet_(API)|rednet]] and wait for responses. In order for this system to work, there must be at least 4 computers used as gps ''hosts'' which will respond and allow [https://en.wikipedia.org/wiki/Trilateration trilateration]. You can set up hosts using the [[Gps (program)|gps program]].
 
   
 
   
 
+
==Methods==
 
{| border="1" cellpadding="2" cellspacing="0"
 
{| border="1" cellpadding="2" cellspacing="0"
 
!style="background:#EEE" width="200px"|Method name
 
!style="background:#EEE" width="200px"|Method name

Revision as of 14:29, 29 May 2012

The gps API provides a method for turtles and computers to retrieve their own locations.

It broadcasts a PING message over rednet and wait for responses. In order for this system to work, there must be at least 4 computers used as gps hosts which will respond and allow trilateration. You can set up hosts using the gps program.

Methods

Method name Description
gps.locate(timeout, debug) Tries to retrieve the computer or turtle own location.

@param timeout the amount of time, in seconds, to wait for a rednet response
@param debug if true, outputs debug messages
@return the computer or turtle own location (x, y, z) or nil if it could not be determined