How do convert XY screen coordinates to XY map tiles and detect region/terrain IDs??

I got a question. How do I get xy screen coordinates from pictures? Something like making projectiles to hit target events or pixelated platforming that interact tiles... Oh and is there a way to get pictures to go behind tiles or events just like they did in rpg2k3? I wanted to make projectiles as pictures to target events without have do all the pasting in every maps.
Nevermind, I found these codes...

$gameScreen.picture(n).x() Get the x-coordinate of the n-th picture
$gameScreen.picture(n).y() Get the y-coordinate of the n-th picture

but it is possible to convert XY screens into XY map?
Yes, you would just put it in Math.round()

E.g.
Math.round($gameScreen.picture(n).x())
Yes, you would just put it in Math.round()

E.g.
Math.round($gameScreen.picture(n).x())
okay. I tried that.

Both codes $gameScreen.picture(n).x() & Math.round($gameScreen.picture(n).x()) acts the same.

The coordinates is coming from the picture but when I move the picture to red tile it doesn't detect the terrain. Same so for region IDs placed in grass and dirt.

So how do I convert screen xy to xy tile coordinates, I'm not really too good at divisions more than multipliers.

Edit: I forgot that the picture stays on screen and there's no way to keep pictures with tilesets. 2k3 also has that feature.




1713473788548.png

1713473780564.png

1713473770109.png


Here's what I put.

◆Show Picture:#1, dice-0, Center (688,544), (100%,100%), 255, Normal
◆Loop
◆Plugin Command:TextPicture, Set Text Picture
: :Text = Picture in Terrain ID: \v[165] Picture in Region ID:…
◆Show Picture:#2, None, Upper Left (8,8), (100%,100%), 255, Normal
◆Control Variables:#0162 Test Picture X = Math.round($gameScreen.picture(1).x())
◆Control Variables:#0163 Test Picture Y = Math.round($gameScreen.picture(1).y())
◆Control Variables:#0164 TP: Speed Value = 2
◆Get Location Info:TP: Region, Region ID, ({Test Picture X},{Test Picture Y})
◆Get Location Info:TP: Terrain, Terrain Tag, ({Test Picture X},{Test Picture Y})
◆If:Button
is being pressed
◆Control Variables:#0162 Test Picture X -= TP: Speed Value
◆
:End
◆If:Button
is being pressed
◆Control Variables:#0162 Test Picture X += TP: Speed Value
◆
:End
◆If:Button [Up] is being pressed
◆Control Variables:#0163 Test Picture Y -= TP: Speed Value
◆
:End
◆If:Button [Down] is being pressed
◆Control Variables:#0163 Test Picture Y += TP: Speed Value
◆
:End
◆Move Picture:#1, Linear, Upper Left ({Test Picture X},{Test Picture Y}), (100%,100%), 255, Normal, 1 frame
◆If:Button [Cancel] is being pressed
◆Script:$gameScreen.clearPictures()
◆Play SE:Cancel1 (100, 100, 0)
◆Transfer Player:Debug (15,6) (Direction: Up)
◆Exit Event Processing
◆
:End
◆Wait:1 frame
◆
:Repeat Above

Original thread: https://forums.rpgmakerweb.com/threads/how-do-convert-xy-screen-coordinates-to-xy-map-tiles-and-detect-region-terrain-ids.167852/