Joseph Posted March 5, 2015 Posted March 5, 2015 How would someone find the position that is under our mouse?
Twin Posted March 5, 2015 Posted March 5, 2015 (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 March 5, 2015 by twin 763
Soldtodie Posted March 5, 2015 Posted March 5, 2015 (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 March 5, 2015 by Soldtodie
VladBots Posted March 5, 2015 Posted March 5, 2015 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)
Soldtodie Posted March 5, 2015 Posted March 5, 2015 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) When you want to get a position that is not loaded.
Botre Posted March 5, 2015 Posted March 5, 2015 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.
VladBots Posted March 5, 2015 Posted March 5, 2015 When you want to get a position that is not loaded. but your mouse can't be over a tile that isn't on camera. 1
Soldtodie Posted March 5, 2015 Posted March 5, 2015 but your mouse can't be over a tile that isn't on camera. Possible but he don't ask for the best way. Anyway thx for the information. 1
Joseph Posted March 5, 2015 Author Posted March 5, 2015 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