Jump to content

Getting nearby objects


rooney

Recommended Posts

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 by rooney
Link to comment
Share on other sites

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 by Khaleesi
Link to comment
Share on other sites

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 ^_^

 

  • Like 1
Link to comment
Share on other sites

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 smile.png

 

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

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...