Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Entities

Featured Replies

So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below.

 

2b4fabf425.png

 

Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with.

 

Cheers,

Chazler

So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below.

 

2b4fabf425.png

 

Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with.

 

Cheers,

Chazler

RS2Object trapdoor = objects.closest("Trapdoor");

A better way to do this is:

if (!myPlayer().isMoving() && inventory.contains("Bucket")) {
   RS2Object trapdoor = objects.closest("Trapdoor");
   if (trapdoor != null)
      if (trapdoor.isVisible())
         trapdoor.interact("Climb-down");
      else
         camera.toEntity(trapdoor);
}

If you want a trapdoor on a specific position you have to use the Filter.

This can filter out everything you want.

 

Example:

if (!myPlayer().isMoving() && inventory.contains("Bucket")) {
   RS2Object trapdoor = objects.closest(new Filter<RS2Object>(){

   @Override
   public boolean match(RS2Object object) {
      return object != null && object.getName().equals("Trapdoor") && object.getPosition().equals(new Position(0, 0, 0));
   }});

   if (trapdoor != null)
      if (trapdoor.isVisible())
         trapdoor.interact("Climb-down");
      else
         camera.toEntity(trapdoor);
}

Goodluck!

Khaleesi

Edited by Khaleesi

So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below.

 

2b4fabf425.png

 

Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with.

 

Cheers,

Chazler

RS2Object thing = objects.closest("Blah");
  • Author
RS2Object trapdoor = objects.closest("Trapdoor");

A better way to do this is:

if (!myPlayer().isMoving() && inventory.contains("Bucket")) {
   RS2Object trapdoor = objects.closest("Trapdoor");
   if (trapdoor != null)
      if (trapdoor.isVisible())
         trapdoor.interact("Climb-down");
      else
         camera.toEntity(trapdoor);
}

If you want a trapdoor on a specific position you have to use the Filter.

This can filter out everything you want.

 

Exmaple:

if (!myPlayer().isMoving() && inventory.contains("Bucket")) {
   RS2Object trapdoor = objects.closest(new Filter<RS2Object>(){

   @Override
   public boolean match(RS2Object object) {
      return object != null && object.getName().equals("Trapdoor") && object.getPosition().equals(new Position(0, 0, 0));
   }});

   if (trapdoor != null)
      if (trapdoor.isVisible())
         trapdoor.interact("Climb-down");
      else
         camera.toEntity(trapdoor);
}

Goodluck!

Khaleesi

 

 

Quick and on the spot as always, much obliged!

pls use braces

pls use getObjects() instead of objects.

make us. :D

I requested alek for a position filter class so check that out op.

Edited by josedpay

make us. biggrin.png

I requested alek for a position filter class so check that out op.

your code gains readability 

make us. biggrin.png

I requested alek for a position filter class so check that out op.

 

We already have a pretty flexible filter class :@

 

Cmoooon man

	public Filter<RS2Object> pls(Position lel) {
		Filter<RS2Object> wat= new Filter<RS2Object>() {
			@Override
			public boolean match(RS2Object mald) {
				return !mald.getPosition().equals(lel);
			}
		};
		return wat;
	}

you see all that code you have to type up. I got tried of doing that. When now we can simply do getObjects().closest(new PositionFilter(position));

 

edit: i know its easy to create a simple method like that. I simply request for the filter because we have many different filters available. It wasnt there when i look at it. It will be handy to others especially the nubs (like me :troll:) and i mean there is a PolygonArea filter (which the PolygonArea class was just recently released) and not a position filter. Which btw in OSB1 there use to be like a method to get an entity using a position. 

Edited by josedpay

Yeah, a more beginner-friendly API isn't a bad thing per se.

And I suppose it takes Alek like 5 seconds to write methods like that.

No reason to be grumpy I guess *flies away*

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.