Jump to content

Get current object myPlayer is interacting with


pigfarmer

Recommended Posts

Hey pigfarmer,

I don't know if this works 

 public RS2Object something() {


        for (RS2Object x:getObjects().getAll()) {
            if (myPlayer().isInteracting((org.osbot.rs07.api.model.Character<?>) x)){
                return x;
            }

        }
        
        return null;
    }

Also you might want to put questions in https://osbot.org/forum/forum/249-scripting-help/ not https://osbot.org/forum/forum/251-snippets/ 

 

  • Boge 1
Link to comment
Share on other sites

1 hour ago, Nbacon said:

Hey pigfarmer,

I don't know if this works 


 public RS2Object something() {


        for (RS2Object x:getObjects().getAll()) {
            if (myPlayer().isInteracting((org.osbot.rs07.api.model.Character<?>) x)){
                return x;
            }

        }
        
        return null;
    }

Also you might want to put questions in https://osbot.org/forum/forum/249-scripting-help/ not https://osbot.org/forum/forum/251-snippets/ 

 

This dose not work unfortunately:(

It seems like you can not cast a RS2Object to a Character :(

Anyone else that knows who this could be done???

Link to comment
Share on other sites

On 6/9/2020 at 3:08 PM, pigfarmer said:

I just want to know if the bot is interacting with a object and if so, what is the object?

Try this

Entity interacting = myPlayer().getInteracting();
if (interacting != null) {
    if (interacting instanceof RS2Object) {
        RS2Object object = (RS2Object) interacting;
    } else if (interacting instanceof NPC) {
        NPC npc = (NPC) interacting;
    }
}
  • Heart 1
Link to comment
Share on other sites

  • 7 months later...
On 6/12/2020 at 9:03 AM, BravoTaco said:

Try this


Entity interacting = myPlayer().getInteracting();
if (interacting != null) {
    if (interacting instanceof RS2Object) {
        RS2Object object = (RS2Object) interacting;
    } else if (interacting instanceof NPC) {
        NPC npc = (NPC) interacting;
    }
}

Did this work?

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