script command to see event dir, coordinates, region id and terrain tag

Hey guys,

Im wondering if theres a script call out there to check the event coordinates, direction region ID and terrain tag, like there is with the player direction. ($gamePlayer.direction() === 2)
This would be incredible useful for me because otherwise i will need to use a large portion of variables with different npc data stored.
There is a topic on this forum about the script equivalents of event commands - check that topic for the equivalent of the "get location info" event command, because that is the event command to load that data into variables.
There is a topic on this forum about the script equivalents of event commands - check that topic for the equivalent of the "get location info" event command, because that is the event command to load that data into variables.
i could only find this one:
https://forums.rpgmakerweb.com/index.php?threads/script-call-equivalent-of-events.6248/
which is for rpg maker vx. Is there perhaps also a version of this for MV?
https://forums.rpgmakerweb.com/index.php?threads/master-more-debug-tool-v-1-5.74843/#post-717912
try my tool
you get all this info in toolbar
and you have script call in plugin
Is there perhaps also a version of this for MV?
Yes, and it's the third sticky in the MV support area
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/
Spoiler: Understand
All of the members you want access to are initialized in Game_CharacterBase, which is parent to both Game_Event and Game_Player.

Only one instance of Game_Player is needed for most RPGs, so by default it is created when a new game is started and stored as a global variable ($gamePlayer).

Being a global variable, $gamePlayer can be accessed from anywhere you want to reference it, which is why you are able to access those members conveniently from within the event command list's script command.

If we can do that for $gamePlayer, surely we can do that for an individual event, right? Yes, we can.

In order to understand how to access the information we want, we have to find out where that information lives and how to communicate with it from our desired location.

In our situation, we want to access it conveniently via the event command list's script command or even the conditional branch's script condition (very useful).

We already know where the information we want is because I mentioned it earlier; the info we want access to lives inside an instance of Game_Event, so the question becomes "how do we access instances of Game_Event via the event command list?"

The magic of the event command list happens inside the Game_Interpreter class; if we look in there, we will find that whenever an instance of Game_Interpreter is setup, the eventId of the instance of the Game_Event the interpreter is running within gets passed down to it.

As you can imagine, we are almost there!

So where are instances of Game_Event instantiated then? Why, in the Game_Map class of course, which conveniently for us is also a global variable ($gameMap). So does Game_Map have a way of gaining access to individual instances Game_Event(s) that are stored in it? Yeah man, you bet.

We have arrived at our destination; by creating a custom function within Game_Interpreter, we can conveniently gain access to a Game_Event.

Code:
Game_Interpreter.prototype.event = function() {
    return $gameMap.event(this._eventId);
};

By adding the function above to Game_Interpreter, you can easily access an event's member variables using the same methods as you do for the player by simply referencing it in the following manner;


Code:
this.event().direction() === 2;
@Jonforum thanks for the link ill give it a try for sure!

@Andar Ahh you meant that one, I already knew of that one. But for some reason I never realised what it really meant.

@dbchest thanks for your thorough tutorial, ive learned alot! but i heard once that its not smart to adjust code in the main .js files. I did figure out something that also works though, thanks to your tutorial, which doesnt require adding to the file. Which is:
$gameMap.event(this._eventId).direction() === 4

Thanks alot people I think ive found all i needed!
@Monkey BizNiz the problem with modifying core-js-files has nothing to do with the code itself, it is just that the core files are the ones that get updated by Degica whenever a new MV-version is released.
Which means that every time that happens, you would have to make the edit again.

Plugins use the same code but override existing functions - that means that it doesn't matter directly for them if the core files get updated (unless the update makes them completely incompatible due to significant core changes)
@Andar Ye i thought that was the case. I think id prefer to use a preexisted script, instead of having to adjust the core files every time and again tho.
@Monkey BizNiz:

The bottom line is that you've found a solution that you're comfortable with. .

Spoiler: Full Response
I didn't mean to suggest that modifying the source code is the best solution to a problem; I just intended to drive home the point that opening up those source files and just having a look around can benefit you in so many ways!
@dbchest dont worry your point came across! and you telling how things work was extremely useful, not just for this situation but also for others to come.

Original thread: https://forums.rpgmakerweb.com/threads/script-command-to-see-event-dir-coordinates-region-id-and-terrain-tag.81747/