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

[Openccsensors] Hunting Turtle

Started by TheEvilSocks, 09 October 2013 - 12:58 PM
TheEvilSocks #1
Posted 09 October 2013 - 02:58 PM
Hiya!

Basically I've been searching for the program Mikeemoo1000 has been using in this video:

[media]http://www.youtube.com/watch?v=3MlKiUPNVQ4[/media]
Any help on finding it?


EDIT on 19-10-2013:
I forgot to mention, I'm playing tekkit 1.1.8 for Minecraft 1.5.2
Bubba #2
Posted 09 October 2013 - 07:34 PM
I bet that Mikeemoo hasn't even posted the code. He was just showing off the awesomeness of his mod.
However, we could help you recreate this. In fact, it probably wouldn't even be that difficult.

You'll want to do a few things:
  1. Find a navigation API that you like. There are about a million of them sitting about on the forums, but you'll want to make certain that it allows you to input relative coordinates that are not based on GPS. You can try out my own navigation API, which was designed to be as small as possible but is still functioning, or you can go ahead and find your own that incorporates more features such as location saving.
  2. Use a sensing turtle from OpenCCSensors to get data on mobs. I don't believe that sensing turtles have been updated to 1.6.2 because OpenCCSensors has been merged with OpenPeripheral, but you should be able to get them for 1.5.2.
  3. Simply have the turtle navigate to the coordinates determined by the sensor and attack until turtle.attack returns false.
This may sound complicated, but it's really not bad. Post your code if you have any issues and I'm sure plenty of people will be willing to provide assistance.
TheEvilSocks #3
Posted 19 October 2013 - 01:08 PM
I bet that Mikeemoo hasn't even posted the code. He was just showing off the awesomeness of his mod.
However, we could help you recreate this. In fact, it probably wouldn't even be that difficult.

You'll want to do a few things:
  1. Find a navigation API that you like. There are about a million of them sitting about on the forums, but you'll want to make certain that it allows you to input relative coordinates that are not based on GPS. You can try out my own navigation API, which was designed to be as small as possible but is still functioning, or you can go ahead and find your own that incorporates more features such as location saving.
  2. Use a sensing turtle from OpenCCSensors to get data on mobs. I don't believe that sensing turtles have been updated to 1.6.2 because OpenCCSensors has been merged with OpenPeripheral, but you should be able to get them for 1.5.2.
  3. Simply have the turtle navigate to the coordinates determined by the sensor and attack until turtle.attack returns false.
This may sound complicated, but it's really not bad. Post your code if you have any issues and I'm sure plenty of people will be willing to provide assistance.

Thanks Bubba!

I've tried somethings now but I can't really figure out how to sensor API works.

I'm terribly sorry for my late reply.
TheEvilSocks #4
Posted 24 October 2013 - 03:42 PM
I hate doing this but: BUMP!
Bomb Bloke #5
Posted 25 October 2013 - 08:17 AM
What exactly have you tried, and what exactly are you getting stuck on? Are you getting particular error messages, or just unsure how to deal with the tables it gives you, or…?
TheEvilSocks #6
Posted 26 October 2013 - 01:17 PM
What exactly have you tried, and what exactly are you getting stuck on? Are you getting particular error messages, or just unsure how to deal with the tables it gives you, or…?

I'm unsure how to deal with the table it gives me. I'm not advanced with lua or anything. The only lua thing I can do is echo things out :P/>
TheEvilSocks #7
Posted 16 November 2013 - 06:07 PM
I still need this
Bomb Bloke #8
Posted 16 November 2013 - 07:05 PM
Ok, let's say you've got a table and you've stored it in "myTable". You've no idea what's in it but you want to find out.

In the table are one or more variables, referred to as "keys". The content of these variables can be anything: strings, numerals, functions, or even more tables.

First off, you want to print out a list of what the table contains. Create a loop:

for key,content in pairs(myTable)
  print(key.." is a "..type(content))
end

This loop repeats once for every variable in the table. At the start of each iteration, the "key" variable gets assigned the name of the current variable in the table, and the "content" variable gets the content of the current variable in the table.

Let's say you run this and you get told that there's a key in there called "name", it's a string, and you want to print that string's contents. You'd call:

print(myTable.name)

Or:

print(myTable["name"])

The latter method is required if the key is a numeral, or has spaces in its name.

If you found another table in myTable (say it was called "1"), you'd then loop through that and see what's in it:

for key,content in pairs(myTable[1])
  print(key.." is a "..type(content))
end

If you found a function in the [1] table inside "myTable" called eg "somefunction", then it'd be called thusly:

myTable[1].somefunction()

And so on.

Generally though, when you've got an unfamiliar table with functions in it, it's time to hunt down the documentation for whatever API it was that gave it to you - functions usually expect you to hand them parameters, and trying to work out what those are on your own is a fool's errand. However, bear in mind that APIs themselves load in as tables (and so do wrapped peripherals, for that matter), so if you use the above example loop on eg "paintutils" instead of "myTable" - then hey presto, you've printed a list of the functions in the paintutils API!