Ayylmao420 Posted April 15, 2017 Share Posted April 15, 2017 was looking through api and couldn't find anything .. either it's not there or i'm just blind but how am i supposed to determine if entity is object/npc/player ? Quote Link to comment Share on other sites More sharing options...
Reveance Posted April 15, 2017 Share Posted April 15, 2017 (edited) Entity is an interface...so you could easily check what object you're dealing with: entity instanceof Player entity instanceof RS2Object But why are you getting entities in the first place? Why not use the Players, Objects classes to get the entities you want instead? Edited April 15, 2017 by Reveance Quote Link to comment Share on other sites More sharing options...
Charlotte Posted April 15, 2017 Share Posted April 15, 2017 https://osbot.org/api/org/osbot/rs07/api/model/Entity.html All Superinterfaces: Identifiable, Interactable, Vector3D All Known Subinterfaces: RS2Object All Known Implementing Classes: Character, GroundDecoration, GroundItem, InteractableObject, NPC, Player, WallDecoration, WallObject Quote Link to comment Share on other sites More sharing options...
Ayylmao420 Posted April 15, 2017 Author Share Posted April 15, 2017 I need it for my custom interaction method to choose the correct menu option, public boolean interactWithEntity(Entity entity, String option) { So for objects it's getUID(), npc getIndex() etc but entity doesn't even give me such methods to check Quote Link to comment Share on other sites More sharing options...
Vilius Posted April 15, 2017 Share Posted April 15, 2017 (edited) 22 minutes ago, Ayylmao420 said: I need it for my custom interaction method to choose the correct menu option, public boolean interactWithEntity(Entity entity, String option) { So for objects it's getUID(), npc getIndex() etc but entity doesn't even give me such methods to check Thats the whole point of having super classes, that they have their own custom methods. What you can do is overload the methods to have diff params depending on the entities super class. Edited April 15, 2017 by Vilius Quote Link to comment Share on other sites More sharing options...
Reveance Posted April 15, 2017 Share Posted April 15, 2017 9 minutes ago, Vilius said: Thats the whole point of having super classes, that they have their own custom methods. What you can do is overload the methods to have diff params depending on the entities super class. Correct, however overloading his method won't work in this case since he'll first need to cast to whatever more specific object it is first, before calling the method, in order for that to work. I think the easiest solution, especially as you only have like 3 or 4 instances to check, would be to use instanceof. I doubt you'd want something fancier in this case... Quote Link to comment Share on other sites More sharing options...