Get the direction an event is facing?

Is it possible to return the direction that an event is currently facing with Javascript?

I've read through the RMMV Script Calls and couldn't find anything
$gameMap.event(x)._direction



Where x is the event's id
You can use the .direction() method.


I.E.


var dir = $gamePlayer.direction();


if (dir === 2) $gameSwitches.setValue(111, 1); 


if the player is facing down when this script call is being ran it will turn on switch 111.


to check events you can use $gameMap.event(this._eventId); or $gameMap.event(#)  //changing # to the number of the event.


oh and for the directions:


Down = 2


Left = 4


Right = 6


Up = 8
Where x is the event's id



Thanks what does that return?

Edit: Found out by testing 2 = down 4 = left 6 = right 8 = up
It will return 2 4 6 or 8 depending on which direction it's facing.
Yes, you can use the following:


$gameMap.event(eventID)._direction


where eventID is the ID of the event.


For example, you can make an event, then give it these event commands:

Code:
◆Control Variables: variableID = $gameMap.event(eventID)._direction
◆Text:None, Window, Bottom
:    :Direction: \V[variableID]

where variableID is storing the direction value, and eventID is the event being checked.  If the event running this command and the eventID are the same (and if the Direction Fix is off), then the event will create a text window every time you interact with it, stating its direction.  To know which direction is which, you can look at your number keypad on your computer:  8 is up (north), 6 is right (east), 2 is down (south), and 4 is left (west).  You can then use the value of the variable to make something happen in your game.


Alternatively, for those who don't need javascript, you can just use a Conditional Branch in your event command to check which direction a given event is facing.  This is easier for most cases of eventing.

Original thread: https://forums.rpgmakerweb.com/threads/get-the-direction-an-event-is-facing.69067/