Jump to content

Examine Random RS2Object


Recommended Posts

Posted

It will be something like:

RS2Object nearestExaminableObject = getObjects().closest(a -> a.hasAction("Examine") && a.getPosition().distance(myPosition()) <= 7);
if (nearestExaminableObject != null) {
nearestExaminableObject.interact("Examine");
} else {
log("Waiting until an examinable object is nearby");
}

Posted (edited)

 

1 hour ago, Czar said:

It will be something like:

RS2Object nearestExaminableObject = getObjects().closest(a -> a.hasAction("Examine") && a.getPosition().distance(myPosition()) <= 7);
if (nearestExaminableObject != null) {
nearestExaminableObject.interact("Examine");
} else {
log("Waiting until an examinable object is nearby");
}

 

Thanks! I see you've called .closest() which only returns a single RS2Object. I was hoping to obtain a List of them all. Do you know if such a thing is possible?

Edited by bobbybill123
Posted
On 12/5/2024 at 4:38 AM, bobbybill123 said:

Oddly enough, even the simple call getObjects().closest(a -> a.hasAction("Examine"));  returns null despite being surrounded by trees with examine text.

To get a list you need to collect the objects like so

List<RS2Object> objectsNearby = mp.getObjects().stream().filter(o -> o.hasAction("Examine")).collect(Collectors.toList());

 

Posted
13 hours ago, DCHILLING said:

To get a list you need to collect the objects like so

List<RS2Object> objectsNearby = mp.getObjects().stream().filter(o -> o.hasAction("Examine")).collect(Collectors.toList());

 

I have tried 

List<RS2Object> nearbyObjects = mp.getObjects().getAll().stream().filter(o -> o.hasAction("Examine")).collect(Collectors.toList());

but this too returns an empty list.

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