Jump to content

Trouble with examining random object.


Chromelte

Recommended Posts

boolean examined = false;
List<RS2Object> allEntities = new ArrayList<RS2Object>();
allEntities = objects.getAll();
				
do {
	RS2Object obj = allEntities.get(random(0, allEntities.size() - 1));
	if (obj != null && obj.hasAction("Examine")) {
		obj.interact("Examine");
		examined = true;
		log(obj.getName() + " examined.");
	}
} while (!examined);
			

I am trying to get a list of all the entities around me and examine one at random.  I seem to be able to get a random object just fine, but it never actually gets past this part.

if (obj != null && obj.hasAction("Examine")) {

Any ideas why?

Link to comment
Share on other sites

ran into this awhile ago. I realized that if an object has a name, then it has the examine option, so you might want to try 

if(object.getName() != null) {}, because for whatever reason, it doesnt appear in the list of interact options (i checked this many times).

 

if you want to interact and examine it, there is also a method for that - object.examine().

 

 

Hope this helped :)

  • Like 1
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...