Jump to content

Get and check id of an object?


Recommended Posts

Posted

I'm not sure you understand the question.

 

Are you asking how to check the ID of an object ? if so go into settings and open the 'Entity Debugger'. Then hover over the entity in question and it will tell you the id.

 

Or....

 

Did you mean how do you get the id of an entity dynamically in the code?

Entity e = objects.closest("name");
int id = e.getId();

Apaec

  • Like 2
  • 1 year later...
Posted (edited)

There are multiple ways of finding objects

 

One is using an id:

RS2Object myObject = getObjects().closest(2565);

Another way would be using the object name:

RS2Object myObject = getObjects().closest("Bank booth");

and if you want to match on a specific variable of an object you could use filters:

Filter<RS2Object> modelIdFilter = new Filter<RS2Object>() {
   public boolean match(RS2Object n) {
      return (n.getModel() == 1234);
   }
};      

RS2Object myObject = self.getObjects().closest(modelIdFilter);

after that you can use myObject.getId() to get the ID value of that object

 

Edit: Just realized when this post was made :(

Edited by Abuse

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...