MZ Check if a map position (x,y) has an event.

I want to check if a certain point in a map (x,y) is passable. Here is my code:

JavaScript:
var playerX = $gamePlayer.x;
var playerY = $gamePlayer.y;
    
var x = 11; //map point x
var y = 10; //map point y
    
var t = $gameMap.isPassable(x, y, 8);

if(!t || (playerX == x && playerY == y))
{
    console.log('not passable');
}
else
{
    console.log('passable');
}

The code works if I put an unpassable tile on the map points as well as if the player stand on it. However, putting an event(priority: same as characters) on the map points returns 'passable'.

How can I know if an event is standing on a map point?
I want to check if a certain point in a map (x,y) is passable. Here is my code:

JavaScript:
var playerX = $gamePlayer.x;
var playerY = $gamePlayer.y;
 
var x = 11; //map point x
var y = 10; //map point y
 
var t = $gameMap.isPassable(x, y, 8);

if(!t || (playerX == x && playerY == y))
{
    console.log('not passable');
}
else
{
    console.log('passable');
}

The code works if I put an unpassable tile on the map points as well as if the player stand on it. However, putting an event(priority: same as characters) on the map points returns 'passable'.

How can I know if an event is standing on a map point?

I'm pretty sure what you're looking for would simply be:
JavaScript:
var x = 11, y = 10;
var eventsAtXY = $gameMap.eventsXyNt(x,y) || [];
var noEvent = !(eventsAtXY.some(v => v._priorityType === 1));
if ($gameMap.isPassable(x, y) && noEvent){
  console.log("passable");
}else{
  console.log("not passable");
};

That will check to see if location spot of x:11 y:10 is passable & doesn't have any non through events with priority as the same as character

Hope that helps?
I'm pretty sure what you're looking for would simply be:
JavaScript:
var x = 11, y = 10;
var eventsAtXY = $gameMap.eventsXyNt(x,y) || [];
var noEvent = !(eventsAtXY.some(v => v._priorityType === 1));
if ($gameMap.isPassable(x, y) && noEvent){
  console.log("passable");
}else{
  console.log("not passable");
};

That will check to see if location spot of x:11 y:10 is passable & doesn't have any non through events with priority as the same as character

Hope that helps?
This is working, thanks!

A question though. What does $gameMap.eventsXyNt(x,y) || [] exactly do?
This is working, thanks!
Awesome! No prob. glad to help out!

A question though. What does $gameMap.eventsXyNt(x,y) || [] exactly do?
That sets eventsAtXY to an array of all the events that don't have the setting "Not Through" turned on and if it doesn't return anything it sets the variable eventsAtXY to a empty array

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

The Game_CharacterBase#canPass method is usually used for full passability checks, e.g.

$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 8);
I.e. "can the player move 1 tile up from where they are now?".

It checks character collisions, tile passability, the Through flag, map boundaries, and any extra passability rules you may have from plugins you're using.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-a-map-position-x-y-has-an-event.147454/