Need a script so on a conditional branch it can tell me if the player can move to 'x' direction or n

Basically, I need a way in the event processing to have a conditional branch like this:


if(player can move left)


{


 do A;


}


else


{


 do B;


}


By can move left I mean that if the player presses the left arrow then the player actually moves 1 tile to the left instead of hitting a wall/obstacle/etc.


Thanks in advance!
Code:
Conditional Branch: Script: $gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, dir)

where dir is 2 for down, 4 for left, 6 for right, and 8 for up


This should take into account whether the player is in a vehicle or not, whether THROUGH is turned on, the passability settings on the map, and whether there is an event in the road.
You are the best.


Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/need-a-script-so-on-a-conditional-branch-it-can-tell-me-if-the-player-can-move-to-x-direction-or-n.61615/