17 posts
Posted 11 March 2013 - 09:40 AM
Hey, all. I've been searching around trying to find a way to move a turtle to a certain location with out setting up 4 gps computers in the sky. I'm trying to find a way to do this because I can see my self easily outmining the 381 block limit of the modems at the highest point in the sky. I've read around and found a thread that was talking about a piece of code that had this sort of system set up before the GPS api became available. The code was way out of my league and I couldn't quite understand it. So, if there is a way to do it, how would I go about having a turtle move back to a chest after each mined area then return to its finishing spot and starting to mine again? I've looked at the wiki and vectors seem to be the thing I should use? I'm using craftOS 1.5
758 posts
Location
Budapest, Hungary
Posted 11 March 2013 - 09:53 AM
You can just operate with the turtle's relative coordinates. I mean, when you want to depart from the chest, your relative coordinates are (0; 0; 0). Every successful* move increments (or decrements) one of the coordiates by 1. When you want to go back to the chest, you just have to look at your relative coordinates. You have to store the current orientation of the turtle, of course. Shout if you need further explanation.
*Every movement function returns true if it was successful.
17 posts
Posted 11 March 2013 - 10:28 AM
Okay, so when it's place its relative coordinates are (0, 0, 0) and whenever it moves its relative coordinates increase/ decrease accordingly? Seems simpleish enough.
edit: Okay, still extremely confused. I can create a vector but how do I get the turtle to move to that vector? What line(s) of code would I use for storing a last known position? This is the part where it starts getting out of my range of knowledge and the wiki isn't really helping that much.
2005 posts
Posted 11 March 2013 - 11:43 AM
You just keep track of the turtle's facing, and have it either increment or decrement a value based on which way it is facing along with axis when you move. You needn't use vectors, because you'll only be moving one block at a time in any given direction.
17 posts
Posted 11 March 2013 - 12:22 PM
Okay, I think I'll be able to work off that.