pigfarmer Posted June 9, 2020 Share Posted June 9, 2020 Hi I am trying to figure out how to get the current RS2Object that the bot is interacting with. I am looking for something like; myPlayer().isInteracting(getObjects().closest(getObjects().getAll()); If someone knows a way to do this, feel free to comment Quote Link to comment Share on other sites More sharing options...
Nbacon Posted June 9, 2020 Share Posted June 9, 2020 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/ 1 Quote Link to comment Share on other sites More sharing options...
pigfarmer Posted June 9, 2020 Author Share Posted June 9, 2020 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??? Quote Link to comment Share on other sites More sharing options...
Nbacon Posted June 9, 2020 Share Posted June 9, 2020 what are doing? does it it have an interface or animation? Quote Link to comment Share on other sites More sharing options...
pigfarmer Posted June 9, 2020 Author Share Posted June 9, 2020 11 minutes ago, Nbacon said: what are doing? does it it have an inteface or animation? I just want to know if the bot is interacting with a object and if so, what is the object? Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted June 12, 2020 Share Posted June 12, 2020 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; } } 1 Quote Link to comment Share on other sites More sharing options...
Ricky Dactyl Posted February 5, 2021 Share Posted February 5, 2021 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? Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted February 5, 2021 Share Posted February 5, 2021 I never tried with a object but I know this works with npc's and players. Quote Link to comment Share on other sites More sharing options...