pigfarmer Posted June 9, 2020 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
Nbacon Posted June 9, 2020 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
pigfarmer Posted June 9, 2020 Author 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???
Nbacon Posted June 9, 2020 Posted June 9, 2020 what are doing? does it it have an interface or animation?
pigfarmer Posted June 9, 2020 Author 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?
BravoTaco Posted June 12, 2020 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
Ricky Dactyl Posted February 5, 2021 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?
Khaleesi Posted February 5, 2021 Posted February 5, 2021 I never tried with a object but I know this works with npc's and players.