Check if an event can move in a certain direction?

Is theres a way or script i can use to check if an event can move up,left,right or down? Im trying to make three even. That if player move up all three event will move up but if one of the three event cant move up all three event wont move. Same as if player cant move up all event wont move
JavaScript:
$gameMap.events()[event_id].canPass(x, y, direction)
// Replace direction with
// 2 = down
// 4 = left
// 6 = right
// 8 = up
JavaScript:
$gameMap.events()[event_id].canPass(x, y, direction)
// Replace direction with
// 2 = down
// 4 = left
// 6 = right
// 8 = up
Thanks for reply. How about x and y? Do i write it x and y or should i replace then with numbers?
Replace it with a number. Or if you want to use it from the current position, it is going to be a bit longer.
Code:
e = $gameMap.events()[event_id]
e.canPass(e._x, e._y, direction)
// Replace direction with
// 2 = down
// 4 = left
// 6 = right
// 8 = up
Replace it with a number. Or if you want to use it from the current position, it is going to be a bit longer.
Code:
e = $gameMap.events()[event_id]
e.canPass(e._x, e._y, direction)
// Replace direction with
// 2 = down
// 4 = left
// 6 = right
// 8 = up
So basically x and y is the location of tile which i want to check. Then the designation is where the event will enter from?
Yes. Actually, it is the opposite, but it can work either way.
If we are going to construct a sentence. It sounds like this.

"Can this event move <direction> from x, y?"
Yes. Actually, it is the opposite, but it can work either way.
If we are going to construct a sentence. It sounds like this.

"Can this event move <direction> from x, y?"
I am late to ask, but is the e.canPass is a boolean so I can use it in a conditional branch, the second question is about x and y value, what is benefit from them if we have already the event ID
I am late to ask, but is the e.canPass is a boolean so I can use it in a conditional branch, the second question is about x and y value, what is benefit from them if we have already the event ID
You might want to check if an event can move through a tile even if it's not currently on it.
I am late to ask, but is the e.canPass is a boolean
It is a boolean.

the second question is about x and y value, what is benefit from them if we have already the event ID
The "canPass" is just a function. This means you can check the x,y tiles somewhere. Although I'm not really sure if this is what you're asking.
It is a boolean.


The "canPass" is just a function. This means you can check the x,y tiles somewhere. Although I'm not really sure if this is what you're asking.
I am asking becuse I tried to use them in a conditional branch and it doesn't work like expected, for example here to test it, it doesn't work.
Spoiler: event test
1683065491564.png
and it shows this error:
Spoiler: error
1683065557976.png
I tried diffrent ID s and it worked even they are not its ID but with its coordinates, and I made about 8 playtests and i made sure it is checking if this event can pass but when I add the expression that replaces the coordinates it doesn't work, and I tried the script for other event and doesn't work
EDIT: I tried to add === true in the script in conditional branch and it still doesn't work
You might want to check if an event can move through a tile even if it's not currently on it.

Isn't event ID enough to return its coordinates and check if it can pass even it is not on it
The thing I'm not sure about is whether the function events() returns an array or hash/object. I don't have MV/MZ code open to check. If it returns an array, then the "event_id" should be actual event id - 1. But it might also break if you delete any event.

Try to type in the console, $gameMap.events()
What does the console print?
Isn't event ID enough to return its coordinates and check if it can pass even it is not on it
What if you want to check if an event can move through a wall tile on the other side of the map from where it is now?
What if you want to check if an event can move through a wall tile on the other side of the map from where it is now?
but how is it possible to check if the event can walk through a wall thile using this script while its purpose from the beginning is to check if the event have a passable tile in a direction?
I ha
The thing I'm not sure about is whether the function events() returns an array or hash/object. I don't have MV/MZ code open to check. If it returns an array, then the "event_id" should be actual event id - 1. But it might also break if you delete any event.

Try to type in the console, $gameMap.events()
What does the console print?
i have written it and it says it is not a function:
Spoiler: console
1683067202269.png
here is the event btw after changing :
Spoiler: event
1683067309056.png
I said in the console
1683071410695.png

It is a powerful debugging tool
but how is it possible to check if the event can walk through a wall thile using this script while its purpose from the beginning is to check if the event have a passable tile in a direction?
That's just the arguments you're currently sending to the function in this particular usage. The function is checking the x,y of tile, not the x, y of an event. You're asking "Can an event (e) pass through (e's current x position, e's current y position, in the direction you give as an argument)
I said in the console
View attachment 260740
It is a powerful debugging tool
You are right, it returns an array
Spoiler: console
1683068485568.png
, I guess your script doesn't work with mv version, I found another similar script and i guess it is working, I am still testing it, here is it in this post:
That's just the arguments you're currently sending to the function in this particular usage. The function is checking the x,y of tile, not the x, y of an event. You're asking "Can an event (e) pass through (e's current x position, e's current y position, in the direction you give as an argument)
i understood now, but then why do we have to enter the event ID? aren't the events the same or is there a case where one event can pass and other not from the same position?
i understood now, but then why do we have to enter the event ID? aren't the events the same or is there a case where one event can pass and other not from the same position?
So you can check if any event on the map can pass through any tile on the map.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-an-event-can-move-in-a-certain-direction.142111/