gps

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. The three in a plane should not be in a line with each other. 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, and z coordinates of the computer, not the modem, as all rednet distances are measured from the block the computer is in.

Also note that you may choose which axes x, y, or z refers to - so long as your systems have the same definition as any GPS servers that're in range, it works just the same. For example, you might build a GPS cluster according to this tutorial, using z to account for height, or you might use y to account for height in the way that Minecraft's debug screen displays.

CHANNEL_GPS = 65534The channel which GPS requests and responses are broadcast on.
locate([timeout[, debug]])Tries to retrieve the computer or turtles own location.
CHANNEL_GPS = 65534Source

The channel which GPS requests and responses are broadcast on.

locate([timeout[, debug]])Source

Tries to retrieve the computer or turtles own location.

Parameters

  1. timeout? number The maximum time taken to establish our position. Defaults to 2 seconds if not specified.
  2. debug? boolean Print debugging messages

Returns

  1. number This computer's x position.
  2. number This computer's y position.
  3. number This computer's z position.

Or

  1. nil If the position could not be established.