April 15, 20178 yr 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 ?
April 15, 20178 yr 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, 20178 yr by Reveance
April 15, 20178 yr 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
April 15, 20178 yr Author 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
April 15, 20178 yr 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, 20178 yr by Vilius
April 15, 20178 yr 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...
Create an account or sign in to comment