[RMMV] Script for Event and Actor Map X,Y

I looked through the Script Call Equivalent post and I did a few searches and didn't find the whole answer to what I was looking for.

I found $gameMap.regionId(x, y); on the Script Call Equivalent page, but I need to know the variable of the Actor's Map X/Y as well as getting an Event's Map X/Y

and also, how would a conditional look to compare the two region ID's to see if they are the same, with an else statement as well?

This is what I am looking for:

If RegionID(Actor X, Y) = RegionID(Event X, Y) then

Else

    if RegionID(Actor X, Y) = RegionID(Event X-1, T) or RegionID(Actor X, Y) = RegionID(Event X+1, T)... ext to check the adjacent map tiles

    else

    End Conditional

End Conditional

Thanks in advance!
You can do this with events, you know - Control Variables will let you get the player's or an event's coordinates - so you'd need 4 of them.

However, in a conditional branch, you can use the following in the script section to see if they are on the same tile - replace # with the event id (EV003 would be 3, not 003):

Code:
$gamePlayer.x === $gameMap.event(#).x && $gamePlayer.y === $gameMap.event(#).y
Just to clarify, I am comparing the region ID's the Actor and events occupy, they may be in 2 different parts of the map but on the same Region ID

So for the condition I would need:

$gameMap.regionId($gamePlayer.x, $gamePlayer.y) === $gameMap.regionId($gameMap.event(#).x, $gameMap.event(#).y)

Why three "===" ?

What is used for "OR"

Do I need to include the ";" at the end of the script in the event script box?

Thanks for your reply!
Just to clarify, I am comparing the region ID's the Actor and events occupy, they may be in 2 different parts of the map but on the same Region ID

So for the condition I would need:

$gameMap.regionId($gamePlayer.x, $gamePlayer.y) === $gameMap.regionId($gameMap.event(#).x, $gameMap.event(#).y)

Why three "===" ?

What is used for "OR"

Do I need to include the ";" at the end of the script in the event script box?

Thanks for your reply!
Shaz has given the way of finding if the Player and Event are on the same tile.

3 equals signs is the same as 2 equals but also checks data types, so normally 0 == false would evaluate to true, but 0 === false would become false.

For your purposes all you need to do is replace the actor's X and Y with $gamePlayer.x and $gamePlayer.y

and the event's X and Y with $gameMap.event(#).x and $gameMap.event(#).x

(Make sure you change # to the event id)

However I'm unsure as to what you're actually trying to achieve with this to be honest, as what you have setup checks if a player and the event are on the same tile graphic.
I was experimenting with a Tiled Lighting system.

I would have 1 event for each tile visible on the screen, in my case 22x14, so 308 events. Each room would be given a different Region ID, when  the player enters Room with Region ID 1, then any other rooms with a different Region ID still visible on screen would be blocked out by changing the graphics on the events, only allowing you to see in the room you are currently in.

I ran into a few issues that I could have worked around but came up with a new way to do the same with only 1 event for each room instead of 308 events moving with the character lol.

Either way it was nice to learn the above!

Thanks!
I know this is late guys but I can't find it anywhere. Is there a way to make a code for THIS event? Like $gameMap.event(#) But instead of an event ID is there a way to tell it to make the action on THIS event? As I want multiple instances on my map but I don't want to have to make a seperate code for every single event.
Necro-post notice: CameronCalvert

This thread is over 2 years old. In addition, your query is different from that of the OP's. In an active thread this would count as hi-jacking a thread.

Please post a new thread, setting out fully what it is you want to achieve.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-script-for-event-and-actor-map-x-y.48227/