Jump to content

Distance to x and y position


Recommended Posts

Posted (edited)

I'm asking to see if it's possible to see how close you are to a specific tile. something like this:

 

if (distanceTo(tile) <6) {

bank();

}else{

webwalk(varrockeast);

}

I know syntax is not correct in example just looking to see if it is possible. I know you can check areas and such but i want to see if you can do it this way. In API I can only see distanceto entity. I'm probably being a bad. Can someone help? if you find it in api can you tell me where you found it too. thanks :)

 

EDIT:

Would shift clicking be hard to implement too? wouldn't know where to start with this.

Edited by mr bot420
Posted

use the.distance(entity) method when trying to calculate the distance

e.g

	if(Banks.GRAND_EXCHANGE.getRandomPosition().distance(myPosition()) < 6) {
	//code
	}
	 
	//another example
	private final Position alohaSnackbar = new Position(x,y,z);
	if(alohaSnackbar.distance(myPosition()) <= 6) //less than or equal to 6 {
	//code
	}
	

  • Like 1
Posted
21 minutes ago, mr bot420 said:

I'm asking to see if it's possible to see how close you are to a specific tile. something like this:

 

if (distanceTo(tile) <6) {

bank();

}else{

webwalk(varrockeast);

}

I know syntax is not correct in example just looking to see if it is possible. I know you can check areas and such but i want to see if you can do it this way. In API I can only see distanceto entity. I'm probably being a bad. Can someone help? if you find it in api can you tell me where you found it too. thanks :)

 

EDIT:

Would shift clicking be hard to implement too? wouldn't know where to start with this.

P.S your player is a entity so .distance(entity) will apply to myPlayer().getPosition() or simply myPosition() both r the same thing i guess

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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