Jump to content

Getting nearby objects


Recommended Posts

Posted (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 by rooney
Posted (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 by Khaleesi
Posted

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)?

Posted

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!

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

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