Which way is the Player facing?

Hiya, it's my first time posting in the learning JavaScript section so yay!


I wanted to know to find out what direction the player is facing, and be able to set a variable to that direction so I can use it in commands like 

Spoiler
$gameMap.startScroll(direction, distance, speed);

which I am using to try make a "Telescope" script!


I have most of it done but I want to know how to find out the direction, so I can scroll in the direction the player is facing!


Thank you for reading and/or helping and hopefully I gave enough detail in my question that it can be answered!
I think the lines you're looking for is in this:

Spoiler
Spoiler





Code:
Game_CharacterBase.prototype.setPosition = function(x, y) {    this._x = Math.round(x);    this._y = Math.round(y);    this._realX = x;    this._realY = y;};Game_CharacterBase.prototype.copyPosition = function(character) {    this._x = character._x;    this._y = character._y;    this._realX = character._realX;    this._realY = character._realY;    this._direction = character._direction;};Game_CharacterBase.prototype.locate = function(x, y) {    this.setPosition(x, y);    this.straighten();    this.refreshBushDepth();};Game_CharacterBase.prototype.direction = function() {    return this._direction;};Game_CharacterBase.prototype.setDirection = function(d) {    if (!this.isDirectionFixed() && d) {        this._direction = d;    }    this.resetStopCount();}


 


 


I may be wrong. I do know directions are even numbers 2, 4, 6, 8.
Thank you! I think this._direction might contain the values  2, 4, 6, 8. as you said, and if so that's perfect! I will go do some testing quickly, thank you!!
That will work if what you're writing is in the Game_Player class.  If it's not (if it's part of the Game_Map class, for example), use $gamePlayer.direction()
That will work if what you're writing is in the Game_Player class.  If it's not (if it's part of the Game_Map class, for example), use $gamePlayer.direction()

Oh! Ok, thanks Shaz!


I guess this can be closed then, since it's solved?

Original thread: https://forums.rpgmakerweb.com/threads/which-way-is-the-player-facing.58584/