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

GPS into Variable

Started by MasterGameLP, 01 April 2012 - 08:05 AM
MasterGameLP #1
Posted 01 April 2012 - 10:05 AM
Hey Guys, (Sorry for my Bad English!) I've trying to put the Coordinates from my GPS System into X, Y and Z Variables.
But I have no ideas how to do this.
Thanks for Help :)/>/>
xuma202 #2
Posted 01 April 2012 - 10:19 AM
You have to use the GPS API


x, y, z = gps.locate(timeout, debug)

Guess that's the way to do it.

If not take a look at the wiki http://computercraft.info/wiki/index.php?title=Gps_(API)
MasterGameLP #3
Posted 02 April 2012 - 05:10 PM
Ok.
And how can I programm that the Turtle go to a special Coordinate???
Luanub #4
Posted 02 April 2012 - 10:16 PM
That's a little more complicated. You will need to figure out a way for the turtle to know and keep track of which direction it is facing. Using a var and assigning it a value between 0 - 3 for north - south and adding or subtracting as you turn should work for that. Then subtract where you want to go from where you are at to get the number of steps that you need to take in order to reach the specified location. From there its just figuring out which directions you need to go and then go. Some of the numbers will probably be negatives, use that to figure out if its north vs south(for example if x == -10 could be 10 steps north, while x == 10 would be 10 steps south). You will have to convert the number to positive if you are going to use it for the turtle to know how far to go.

It would probably be best to either make a series of functions for this, or even better an API. I know there is one API already posted that does this, and I have one of my own that is not posted that I could share if you need.

Definitely a fun project.