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

I need a program to seek out and kill any players within a 200 block radius

Started by Kloudkicker, 06 April 2016 - 10:47 PM
Kloudkicker #1
Posted 07 April 2016 - 12:47 AM
So, title says it all… Trying to make a futurama themed area and this program on five or six turtles connected to an advanced computer would be really cool. So, I would like each turtle to seek a different player, report this to the advanced computer, tell me when they find the player and the username of the player, then kill the player and report back to their stall. Could someone please help with this? Also I will be using any kind of turtle and have extensive resources to dedicate to this. If you need more info just ask and I will try to be as detailed as possible.
Bomb Bloke #2
Posted 07 April 2016 - 01:53 AM
Difficult to help you without knowing how much you've accomplished thus far, how familiar you are with Lua (or programming in general), etc. I'll tell you that, as is the case with all things Minecraft, the key resource you're going to need are "time" and "enthusiasm".

So let's assume you've read the documentation for CC's APIs - in particular, the rednet and turtle APIs - and have a basic understanding of tables and so on.

You'll first need a method tracking where all your turtles are. A GPS system makes this easy, and your turtles are going to need to carry wireless modems in order to communicate with the server computer anyway.

Next you'll need a method of tracking where the players are. Neither advanced computers nor turtles generally have this capability, but with an add-on mod such as OpenCCSensors, you can set up a sensor (or a number of sensors, for the size of the area you're intending to cover) and use them as peripherals.

After that, you'll want to write up some code to handle moving the turtles. They've got to be able to move around, keeping track of their position as they go, to where ever the sensors are telling them their target players are. You'll probably find it easiest to have the advanced computer handle all the sensors and use rednet to pass that information on to the turtles.

Once you've got all that set up, the rest is relatively straight-forward: the turtles follow the players, and swing their swords until said players don't show up on the sensors any more. Then you simply have them return to their pre-defined starting locations and you're done.