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
Check if an event can move in a certain direction?
RPG Maker MV Support
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
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?"
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
You might want to check if an event can move through a tile even if it's not currently on it.
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.
EDIT: I tried to add === true in the script in conditional branch and it still doesn't work
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
Try to type in the console,
What does the console print?
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?
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
here is the event btw after changing :
i have written it and it says it is not a function:
I said in the console
It is a powerful debugging tool
It is a powerful debugging tool
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)
You are right, it returns an array
How to check if an event can move in a certain direction?
I wanted to have an event that constantly flees from the player when they get within range. I can do that fine. But I don't want the player to actually be able to touch the event (it's just a prop to set mood). The way the default pathfinding works, if it hits a wall, it won't move left or...
forums.rpgmakerweb.com
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/