Jump to content

how to check for closest two objects?


Recommended Posts

Posted

I have a simple hunter script I'm working on which works for 1 trap, but I dont know how to make it work for multiple traps. This is due to the fact that I use :

 

Entity ready = objects.closest(9345);

 

as a means of detecting my traps. objects.closest only works on one object so I need to find a way to deal with multiple. Thanks :)

Posted

I have never had a need to do this, but you can just store one:

 

 

Entity ready = objects.closest(9345);

Entity second = objects.closest(new Filter blah blah 

     in this filter return false if the object.equals(ready));

 

but if it returns false when the closest object is ready, would it pick up the closest object after ready ,or would it just be null basically?

Posted

but if it returns false when the closest object is ready, would it pick up the closest object after ready ,or would it just be null basically?

 

 

Are you trying to check if a trap fell? If so you only need to store one fallen trap. If you have a loop going, and you are constantly checking for a closest object (the fallen trap), say you have 2 fallen traps, it will store the first one, then you can operate on it, i.e. pick it up and reset it. Then the loop goes again checking for another fallen trap, you just set one, so there is one left on the ground, it will then store that one, you put it back up, and move on. You just need to check for one fallen trap. If you store multiple fallen traps you will over complicate your script unnecessarily. You cant operate on more than 1 fallen trap at a time anyway.

Posted

alright i tried the filter and it works smile.png thanks a lot friends. also if you are using object entities and you are in a place where there a shit ton of objects(like the jungle) will all these objects mess up the bot trying to find a specific object?

 

If i'm reading this correctly, no it shouldn't objects.closest("whatever string" or whatever id) you have in here will only be looked for, not anything else.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...