nolanri Posted February 9, 2017 Share Posted February 9, 2017 (edited) For future reference, since this was frustrating to calculate. Here is the method for all to use. it calculates the grid square that your mouse is over based on screen size and properly accounts for the Zoom level as well. using the center of the screen as a starting point. local sw = (128 / getCore():getZoom(0)); local sh = (64 / getCore():getZoom(0)); local mapx = getPlayer():getX(); local mapy = getPlayer():getY(); local mousex = ( (getMouseX() - (getCore():getScreenWidth() / 2)) ) ; local mousey = ( (getMouseY() - (getCore():getScreenHeight() / 2)) ) ; local sx = mapx + (mousex / (sw/2) + mousey / (sh/2)) /2; local sy = mapy + (mousey / (sh/2) -(mousex / (sw/2))) /2; local TheSquareYourMouseIsOn = getCell():getGridSquare(sx,sy,getPlayer():getZ()); Edited February 9, 2017 by nolanri Arsenal26, Nebula, hunger john and 2 others 4 1 Link to comment Share on other sites More sharing options...
Arsenal26 Posted November 17, 2020 Share Posted November 17, 2020 Helped alot... Thanks Nolan Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now