rooney Posted June 24, 2014 Share Posted June 24, 2014 (edited) Which methods do I utlize to create instances of GroundItems/other entities? I am trying to create an object for a bank-booth, an attackable NPC and an item on the ground. In OSbot 1 these methods look like: GroundItem herb = SomeClass.closestGroundItemForName("Herb") NPC druid = SomeClass.closestAttackableNPCForName("Chaos druid") etc. I look forward to your guys' help, in the mean time I'm going to dive back in to the API docs to see if I can find an answer Edited June 24, 2014 by rooney Link to comment Share on other sites More sharing options...
Khaleesi Posted June 24, 2014 Share Posted June 24, 2014 (edited) Which methods do I utlize to create instances of RS2Objects? I am trying to create an object for a bank-booth, an attackable NPC and an item on the ground. In OSbot 1 these methods look like: GroundItem herb = SomeClass.closestGroundItemForName("Herb") NPC druid = SomeClass.closestAttackableNPCForName("Chaos druid") etc. I look forward to your guys' help, in the mean time I'm going to dive back in to the API docs to see if I can find an answer RS2Object object = objects.closest(); NPC npc = npcs.closest(); same for the other objects If you want to get those in another class you'll have to pass the Script object Edited June 24, 2014 by Khaleesi Link to comment Share on other sites More sharing options...
triggamortis Posted June 24, 2014 Share Posted June 24, 2014 (edited) http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html#closest(boolean, java.util.Collection) all the methods and the above person to create an instance of it. Edited June 24, 2014 by triggamortis Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 24, 2014 Share Posted June 24, 2014 As stated above, using: RS2Object temp = objects.closest("Name here"); GroundItem i = grounditems.closest("Name here"); NPC n = npcs.closest("Name here"); It is definitely worth jumping into the API and familiarizing yourself with it, also make sure you import the correct objects and not the legacy ones ^_^ 1 Link to comment Share on other sites More sharing options...
rooney Posted June 24, 2014 Author Share Posted June 24, 2014 RS2Object object = objects.closest(); NPC npc = npcs.closest(); same for the other objects If you want to get those in another class you'll have to pass the Script object Ooo thank you very much! Now I understand inheritance much better. I didn't see the closest() method because I was only looking at the methods that were specific to each class, though all of these classes (grounditem, npc etc.) are subclasses of the Entity class. Can you clarify what you mean by having to pass the Script object? Currently I am working on my first script and I have only one class file. I assume you mean something about having separate class files. Would the Script object be passed into the constructor? So something like druidKiller(Script sA)? Link to comment Share on other sites More sharing options...
Khaleesi Posted June 24, 2014 Share Posted June 24, 2014 Ooo thank you very much! Now I understand inheritance much better. I didn't see the closest() method because I was only looking at the methods that were specific to each class, though all of these classes (grounditem, npc etc.) are subclasses of the Entity class. Can you clarify what you mean by having to pass the Script object? Currently I am working on my first script and I have only one class file. I assume you mean something about having separate class files. Would the Script object be passed into the constructor? So something like druidKiller(Script sA)? Yes you can pass it in the constructor Like this: public class AlKharidKiller { private Script script; public AlKharidKiller(Script script){ this.script = script; } Goodluck If you got anymore question you can always add me on skype! Link to comment Share on other sites More sharing options...
Joseph Posted June 25, 2014 Share Posted June 25, 2014 Because your only using one class, you can extend the script class. Rather than initialing it in you constructor. Since your extending script, you inherit all there sub class and methods. Good luck on your script Link to comment Share on other sites More sharing options...