Difference between revisions of "Gps (API)"
From ComputerCraft Wiki
(Updated to API overview v2) |
|||
Line 1: | Line 1: | ||
− | The | + | The GPS API provides a method for turtles and computers to retrieve their own locations. |
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 [[Wikipedia:Trilateration|trilateration]]. Three of these hosts should be in a plane, and the fourth should be either above or below the other three. 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 [[Wikipedia:Trilateration|trilateration]]. Three of these hosts should be in a plane, and the fourth should be either above or below the other three. 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 computer, not the modem, as all rednet distances are measured from the block the computer is in. <!-- do not edit this without actually testing it yourself --> | + | Note: When entering in the coordinates for the ''host'' you need to put in the x,y,z of the computer, not the modem, as all rednet distances are measured from the block the computer is in. |
+ | <!-- do not edit this without actually testing it yourself --> | ||
− | = | + | <table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> |
− | + | <tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;"> | |
− | + | [[File:Grid_disk.png|24px]] | |
− | + | Gps (API) | |
− | + | </td></tr> | |
− | + | ||
− | + | <tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | |
+ | |||
+ | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">gps.locate(timeout, debug)</td> | ||
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tries to retrieve the computer or turtles own location.<br /> | ||
''@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 location (x, y, z) of the modem attached to the computer or turtle or nil if it could not be determined | + | ''@return'' the location (x, y, z) of the modem attached to the computer or turtle or nil if it could not be determined</td></tr> |
− | + | ||
+ | </table> | ||
+ | |||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 22:10, 30 November 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. Three of these hosts should be in a plane, and the fourth should be either above or below the other three. 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 computer, not the modem, as all rednet distances are measured from the block the computer is in.
Method Name | Description |
gps.locate(timeout, debug) | Tries to retrieve the computer or turtles own location. @param timeout the amount of time, in seconds, to wait for a rednet response |