This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
srspore's profile picture

Looking for the gps.locate() source code.

Started by srspore, 23 April 2017 - 06:02 PM
srspore #1
Posted 23 April 2017 - 08:02 PM
I've been using the built in gps api to get the locations of my turtles; however, this causes a lot of rednet chatter, with the turtles broadcasting "PING." This interferes with other communications. My goal is to create a new gps system where the turtles simply send "PING" to only the gps host id. I've attempted to go through the math of triangulation but failed. I've looked through the default gps program and I don't see where the function gps.locate() is defined.


-- Excerpt from the default gps file.
if sCommand == "locate" then
  if open() then
	gps.locate( 2, true ) -- this is the function I am looking for.
  end

elseif ...

If anyone knows where the code that does the triangulation math is, or if anyone knows of code that already does what I'm looking for let me know.

Thank you!
Bomb Bloke #2
Posted 24 April 2017 - 12:54 AM
https://github.com/alekso56/ComputercraftLua/blob/master/rom/apis/gps#L58

Although, if the default ping messages are causing your other systems problems, I'd say your real problem lies within how those systems are handling their own communications. If they fail alongside the GPS system they'll likely fail alongside any other.

Rednet's protocol system is one easy method of ignoring unwanted messages.
Edited on 23 April 2017 - 10:55 PM