Return Tile Coords On Click

Hi everyone, perhaps someone could help me out here. I've seen a few posts that show how to get the x,y coordinates of your mouse click but what I would like to do is to get the x,y coordinates of a tile that I click on the map.

What I know how to do:

I know to get the x,y coordinates (tilemap) of an event and store them in variables as well as getting the x,y coordinates (in pixels) of a click on the map and store them in variables.

What I want to know how to do:

I would like to know how to store the x,y coordinates (tilemap) of the tile I click on the map in variables.

Example: $gameVariables.value(a) = (x coordinate of the tile I click)

                $gameVariables.value(d) = (y coordinate of the tile I click)

I was looking around in the core plugin but I couldn't find where to get anything besides pixel coordinates.

Thank you
Sorry if I'm wrong here, because I'm kind of confused. But I think what you're looking for is:

$gameTemp.destinationX()// and$gameTemp.destinationY()Both of those are set whenever you click during Scene_Map inside the .processMapTouch() specifically this part:

var x = $gameMap.canvasToMapX(TouchInput.x);var y = $gameMap.canvasToMapY(TouchInput.y);$gameTemp.setDestination(x, y);The $gameMap.canvasToMapX() is what converts the touch position to the grid coordinate. Touch doesn't matter what you click on. It set be set if you click on an event or a tile.
Thanks Quasi, you're the best. This is exactly what I was looking for!
Sorry if I'm wrong here, because I'm kind of confused. But I think what you're looking for is:



$gameTemp.destinationX()// and$gameTemp.destinationY()


Both of those are set whenever you click during Scene_Map inside the .processMapTouch() specifically this part:



var x = $gameMap.canvasToMapX(TouchInput.x);var y = $gameMap.canvasToMapY(TouchInput.y);$gameTemp.setDestination(x, y);


The $gameMap.canvasToMapX() is what converts the touch position to the grid coordinate. Touch doesn't matter what you click on. It set be set if you click on an event or a tile.

tanxxxx
For get true coordonate use this in script


$gameMap.canvasToMapX(TouchInput.x) * $gameMap.tileWidth();


Very cool for use Bind picture

Original thread: https://forums.rpgmakerweb.com/threads/return-tile-coords-on-click.51365/