Jump to content

Examine Random RS2Object


bobbybill123

Recommended Posts

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");
}

Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

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());

 

Link to comment
Share on other sites

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.

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