Ace to MV Script Translation

I found this script call for Ace from a tutorial and tried to convert it to MV but was unsuccessful. If someone out there with the knowledge that could enlighten me with the translation I would forever be in your debt and be very much appreciated!


(($game_map.events[@event_id].x - $game_player.x).abs + ($game_map.events[@event_id].y - $game_player.y).abs) == 1


I also have this one if you are feeling extremely smart today:


($game_map.events[@event_id].y - $game_player.y).abs <= 3 && $game_map.events[@event_id].x == $game_player.x || ($game_map.events[@event_id].x - $game_player.x).abs <= 3 && $game_map.events[@event_id].y == $game_player.y
Code:
$game_map.events[@event_id]  = $gameMap.event(this._eventId)
$game_player = $gamePlayer
(code).abs = Math.abs(code)
$game_map.events[@event_id]  = $gameMap.event(this._eventId)
$game_player = $gamePlayer
(code).abs = Math.abs(code)


Thank you, I tried but not able to get it to work either. Not sure if it's asking for player code, if so what would the player code be? 


Sorry JS noob here 🙂



Also, should there be a double empty space after the [@event_id] ?
The first script call is just checking if the distance between player and specified event is less than or equal to 1. Basically if you're adjacent to the event or you're on top of it.


var event = $gameMap.event(this._eventId);
var player = $gamePlayer;
(Math.abs(event.x - player.x) + Math.abs(event.y - player.y)) == 1;


You can probably figure out the second one from this.
Well, I have it some what working. This is the event I have set up:


Screenshot (97).png


The Ace Script I translated in the conditional branch is this:


$gameMap.event(this._eventId).x - Math.abs($gamePlayer.x) + $gameMap.event(this._eventId).y - Math.abs($gamePlayer.y) == 3


Which works fine if the player is to the left or above the event:


Screenshot (98).png


Nothing happens if the player is on the right on under the event, but if the player is diagonal left up or down (no matter how many tiles) the event triggers:Screenshot (95).png


I'm almost there I know it!! 🙂


If anyone with a clue and has got moment, I'd much appreciate the help.

Original thread: https://forums.rpgmakerweb.com/threads/ace-to-mv-script-translation.56312/