Jump to content

how to check for closest two objects?


eleax

Recommended Posts

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 :)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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