Hey Poupuille,
to be honest, I'd rather like to encourage you to try it on your own. Because for one, you'll most probably encounter many more situation where you'll need to track the x and y coordinates of players and events, and this is also very basic knowledge. It will pay off in the future if you learn those things now. And second, unfortunately I have a pretty slow internet connection and deploying a game with even the minimum of graphics (speaking of just one tileset, nothing else) results in a package of 86MB (unzipped), which would take me very long and probably several attempts to upload.
But of course I see how you may struggle with all the javascript. Sorry, I didn't want to confuse you.
If you like we can try to event that structure. Plus, if you tell me/us where exactly you are struggling with, we can surely help you out.
For an solution that relies purely on eventing, you'd want to start with a loop. Afterwards store the X and Y coordinates of the events in different variables. You can also store the coordinates of the other event you're currently not moving outside of the loop.
Then you need to check which direction the player (or event, because they both will 'look' in the same direction, but some events might have a fixed direction) is looking. You have to add oder substract 1 from either the X/Y coordinates of the moving event, depending on which direction the event faces. This will let you check the tile which lies in front of your event. You can see the X/Y coordinates of the map on the right side of the bottom information bar seen in the map editor. As an example, if your character is facing right, you have to add 1 to the variable where the x value of the moving event is stored.
After you've gone through checking all the directions, you should be able to continue outside of the if structure. Next you'll have to store the region id of the tile in question in a new variable. You'll find the function on the third page of the event editor (Get Location Info...). If the reagion ID variable is Z (the one you've chosen), break the loop, else check if the X/Y variables of the two events are the same (if variable 1 = variable 2), if yes, break the loop - else do nothing. After all that stuff, let the event move one tile away from the player.
And that should already do the trick.
The above suggestion is just a blueprint, as I have not tested/evented it. There might emerge subsequent problems, but it's a start. The preparations won't change. You'll need to mark the border and set the event conditions properly.
Feel free to ask for help, if you have trouble with something. I wish you best of luck
🙂
[Edit] The smart part of me that returned from vacation today suggested that instead of sending a project I could just copy paste the code you need to fill in the if clauses.
Spoiler: Javascripties
$gameMap.regionId($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y + 1) === 1
$gameMap.event(this._eventId).x == $gameMap.event(2).x && $gameMap.event(this._eventId).y == $gameMap.event(2).y -1
-
$gameMap.regionId($gameMap.event(this._eventId).x -1, $gameMap.event(this._eventId).y) === 1
$gameMap.event(this._eventId).x == $gameMap.event(2).x +1 && $gameMap.event(this._eventId).y == $gameMap.event(2).y
-
$gameMap.regionId($gameMap.event(this._eventId).x + 1, $gameMap.event(this._eventId).y) === 1
$gameMap.event(this._eventId).x == $gameMap.event(2).x -1 && $gameMap.event(this._eventId).y == $gameMap.event(2).y
-
$gameMap.regionId($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y - 1) === 1
$gameMap.event(this._eventId).x == $gameMap.event(2).x && $gameMap.event(this._eventId).y == $gameMap.event(2).y + 1