Difference between revisions of "Gps (API)"
From ComputerCraft Wiki
(Undo revision 1972 by 91.121.27.33 (talk) Removing spam) |
(added a not about host/client gps coordinates) |
||
Line 2: | Line 2: | ||
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]]. | ||
− | + | ||
+ | Note: When entering in the coordinates for the ''host'' you need to put in the x,y,z of the modem, not the computer. | ||
==Methods== | ==Methods== | ||
{| border="1" cellpadding="2" cellspacing="0" | {| border="1" cellpadding="2" cellspacing="0" | ||
Line 12: | Line 13: | ||
''@param'' '''timeout''' the amount of time, in seconds, to wait for a rednet response<br /> | ''@param'' '''timeout''' the amount of time, in seconds, to wait for a rednet response<br /> | ||
''@param'' '''debug''' if true, outputs debug messages<br /> | ''@param'' '''debug''' if true, outputs debug messages<br /> | ||
− | ''@return'' the | + | ''@return'' the location (x, y, z) of the modem attached to the computer or turtle or nil if it could not be determined |
|} | |} | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 04:42, 7 July 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.
Note: When entering in the coordinates for the host you need to put in the x,y,z of the modem, not the computer.
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 |