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

Turtle Following You

Started by MineFarms, 18 June 2014 - 01:34 AM
MineFarms #1
Posted 18 June 2014 - 03:34 AM
Like the title says I am trying to make a program where the turtle will follow you anywhere you go. Without crashing into blocks in front, below, above, behind and so on. But the problem is I don't know what to do. So I need alittle help. I want a program like cookiebals program Turtle platform. But the problem is he took down the program. So that lead me to here. :)/>
Bomb Bloke #2
Posted 18 June 2014 - 04:23 AM
I guess start off with a GPS system - rig up a turtle that knows where it is, and can make its way to a given location.

Worry about tracking the player once that's done.
Turkey #3
Posted 18 June 2014 - 03:40 PM
If you want to have it follow you while you move, then you'll have to have gps coverage for the area. Be aware that wireless modems have a maximum range of 381 meters, so you'll need multiple gps networks if you want it to follow you over a long distance. See the gps API.

You'll need your PDA to transmit your gps coordinates to the turtle. Transmission of data can be done using the rednet API and the rednet tutorial.

You'll probably want your turtle to record the path you took, since it should be able to follow that path without bumping into anything if takes that path. For this, you'll want to use tables. See the table API and the table tutorial.

To simultaneously move and listen for rednet messages, you'll probably want to have two scripts running on the turtle. To do this, you can use the fg or bg shell commands.

To get these scripts to communicate together, you'll probably want to use the file system. See the fs API. Basically, you'd take a message from one of the scripts (the rednet receiver) and save it in a file. The other script (to handle movement) would periodically check that file to see if it has been updated with new coordinates. If so, it would need to add those coordinates to the list it's trying to follow. It would then need to write a message in another file to tell the rednet script that it got this information and it's safe to update the coordinates file with new information.

Finally, you'll need the turtle to move and follow those coordinates, so see the turtle API.

Like Bomb Bloke said, it's better to start with easy parts and work your way up from there. Get a gps system working. Get a turtle which can move to gps coordinates. Learn how to use rednet to send messages. Learn how to use the file system to let two scripts talk to each other, so you can type commands into one script and have that script communicate with another script. Send gps coordinates from your phone to the turtle. Set up your turtle so it can simultaneously receive gps coordinates and move. Ask questions if you need any help with any of this.
Edited by