Jump to content

getting position


Recommended Posts

Posted (edited)

mouse.getPosition() unless that's not what you wanted.

   

Unless this gets the x/y of where the mouse is on the osbot client and not what's under the mouse, but I was under the impression that this gets the in game cords.

Edited by twin 763
Posted (edited)


public Position getPositionUnderMouse(Point mousePosition) {

for(int x = 0; x < 104; x++) {

for(int y = 0; y < 104; y++) {

Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());

if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {

return pos;

}

}

}

return null;

}

Edited by Soldtodie
Posted
	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

don't check all the tiles in the region, just get the tiles around the local player and check them (iirc the landscape only draws max 25 tiles from the cameras location)

Posted
	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

 

If you use this, make sure you only call this method when clicking.

Not the kind of method you want to call every couple of ms.

Posted
	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

thanks for this you gave me the idea.

 

don't check all the tiles in the region, just get the tiles around the local player and check them (iirc the landscape only draws max 25 tiles from the cameras location)

thats exactly what im going to do. Thanks for the info

 

If you use this, make sure you only call this method when clicking.

Not the kind of method you want to call every couple of ms.

i want it to be like the hover  debug where it still me the current tile.

 

Entity hover debug i think

i want the api version

 

mouse.getPosition() unless that's not what you wanted.

   

Unless this gets the x/y of where the mouse is on the osbot client and not what's under the mouse, but I was under the impression that this gets the in game cords.

that returns a point the x and y of the mouse position

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...