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

GPS Advantages Vs. Hardcoding

Started by River_Chief, 03 November 2012 - 12:45 PM
River_Chief #1
Posted 03 November 2012 - 01:45 PM
Pro's,

After spending weeks tweaking someone else's mining program, I've added some nice entry level refueling and drop off functionality. Next? I thought I'd look into learning the GPS features. After setting up the array, establishing the positions and making sure a turtle can find it's position - I don't see the advantage.

Hard coding a turtle's starting position and assigning it an area to mine, pause, conclude and come home is fairly straightforward without GPS.

What advantages does GPS offer over your standard hard coded "GOTO" code?
Lyqyd #2
Posted 03 November 2012 - 01:49 PM
The ability to determine your position and orientation after a server restart, regardless of where you were in the task.
ElvishJerricco #3
Posted 03 November 2012 - 02:24 PM
It's mostly so the turtle doesn't have to keep track on it's own where it is. This way if any error occurs that wasn't accounted for (like a player being in the way while it moves) then it can still know exactly where it is.

But let's say you're a decent programmer who accounts for everything! What're the advantages then?

Well, the only real advantage then is that the GPS API is way easier to use and write than a home-brewed thing.
ChunLing #4
Posted 03 November 2012 - 03:49 PM
I'd say the main advantage is if you're using rednet to remote control the turtle. If you're not using rednet for other things, then it's sorta a waste.
River_Chief #5
Posted 04 November 2012 - 01:27 PM
Just as I feared…..3 excellent yet different recommendations/answers…. BSGSamuel wrote the original quarry code - it covers orientation through all 4 directions and tracks it's own movement. Although the code is around 400 lines, it is fairly straight forward and ultra reliable. With the attack mode for players/MOBs and the ability to handle gravel/sand - I've never seen it NOT finish tasking.

But as all of you implied - If I start a huge 30 turtle quarry, get distracted elsewhere in the world and log off - finding 30 turtles and getting back "Home" for a quarry restart is incredibly annoying.

With 30 wireless turtles that have their quarry software loaded via disk back in a "Home" position that are now "Stuck" after a relog - is it possible to get them home without interacting with them directly? Can I push out a goto job 30 times easily?

THAT would push me towards getting a deeper understanding of how the GPS API works.
Lyqyd #6
Posted 04 November 2012 - 02:14 PM
If their startup program interacts with the GPS hosts, they could determine through their current inventory, fuel level and location what they should be doing currently. They would then resume from that position whatever they should have been doing.
River_Chief #7
Posted 04 December 2012 - 04:27 AM
To clarify a related problem. Is there any way to reestablish a connection to a turtle after re-logging without physically clicking on it (Turning it back on). If I have a fleet of turtles mining out a designated area, and I log off, it will usually be at the worst possible time. When I come back, 10 of them will be off under 5 blocks of lava.

How do you reestablish a connection in this scenario?
Orwell #8
Posted 04 December 2012 - 04:52 AM
Turtles should automatically turn back on if the chunk gets loaded again. So if you're able to stay close enough for those chunks to load, or if you have chunk loaders available, then that's no problem. Reestablishing the connection is just a matter of a startup script on the turtle that either listens for the server or connects to the server (I suggest the latter).