gps.locate
gps.locate Function | |
---|---|
Syntax gps.locate() | |
Returns | nil | number x, number y, number z |
API | gps |
Source | CC:Tweaked (source) |
When called, sends out a ping to any listening GPS hosts, which in turn will send their own coordinates. Using these coordinates and the signal distance, using trilateration the GPS api can acquire its own location. If for any reason the GPS locating failed, the returned x, y and z will be nil. A Wireless Modem must be attached and GPS Hosts must be in range for the GPS location to succeed.
|
|||
Acquiring the executing computer's own location and printing it on screen. | |||
Code | local x, y, z = gps.locate()
if x == nil then
error("Could not acquire current location. Perhaps there's no wireless modem attached or we're out of range of any GPS hosts.")
else
print("Current location is: ", x, y, z)
end
|
||
Output | Current location is: 38 65 392 |