Jump to content

Obtaining a list of InteractableObjects


elemt

Recommended Posts

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.InteractableObject;
import org.osbot.rs07.api.model.RS2Object;

/**
 * Get InteractableObjects
 * @author FrostBug
 */
public class InteractableFilter implements Filter<RS2Object> {

	@Override
	public boolean match(RS2Object v) {
		return v instanceof InteractableObject;
	}
	
}

List<RS2Object> interactableObjs = getObjects().filter(new InteractableFilter());

  • Like 2
Link to comment
Share on other sites

import org.osbot.rs07.api.filter.Filter;import org.osbot.rs07.api.model.InteractableObject;import org.osbot.rs07.api.model.RS2Object;/** * Get InteractableObjects * @author FrostBug */public class InteractableFilter implements Filter<RS2Object> {	@Override	public boolean match(RS2Object v) {		return v instanceof InteractableObject;	}	}
List<RS2Object> interactableObjs = getObjects().filter(new InteractableFilter());
Or just

List<RS2Object> interactableObjs = getObjects().filter(o -> o instanceof InteractableObject);
Edited by fixthissite
  • Like 1
Link to comment
Share on other sites

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.InteractableObject;
import org.osbot.rs07.api.model.RS2Object;

/**
 * Get InteractableObjects
 * @author FrostBug
 */
public class InteractableFilter implements Filter<RS2Object> {

	@Override
	public boolean match(RS2Object v) {
		return v instanceof InteractableObject;
	}
	
}

List<RS2Object> interactableObjs = getObjects().filter(new InteractableFilter());

 

Thank you! I did this to get cardinal direction ores around my player.

@SuppressWarnings("unchecked")
private void filterRocks() {
	this.rocks = getObjects().filter(new Filter<RS2Object>()
	{
		@Override
		public boolean match(RS2Object v) {
			if(v instanceof InteractableObject) {
				if(((InteractableObject)v).getName().equals("Rocks")) {
					int myX = myPlayer().getX();
					int myY = myPlayer().getY();
					int rockX = v.getX();
					int rockY = v.getY();
					
					return (Math.abs(myX - rockX) == 1 && myY == rockY) || 
					       (Math.abs(myY - rockY) == 1 && myX == rockX);
				}
			}
			return false;
		}
	});
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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