MV Asking event to get its own position

I assume this is possible via JavaScript; I want to ask an event to get its own X position and own Y position, and store those in variables.

I can't say "get X and Y of event #24"; this is a script page within event #24 and I want to be able to say something like:

Variable 250 = self.x

or something to that effect.

Can that be done?
$gameMap.event(eventId).x
$gameMap.event(eventId).y

with those two script calls you can get x and y (position of event) - set to your game variables and done.
$gameMap.event(eventId).x
$gameMap.event(eventId).y

with those two script calls you can get x and y (position of event) - set to your game variables and done.
Hey, sorry but this isn't what I asked.

I need to do this:

$gameMap.event(self).x

Is that possible?

EDIT: Thanks for trying to help @Soulrender, it's this:

$gameMap._events[this._eventId]._x;
or $gameMap.event(this._eventId).x, but basicly it's the same, but looks more nice.
$gameMap.event(eventId).x
$gameMap.event(eventId).y

Hey, sorry but this isn't what I asked.
Actually, it is. As far as you described in your request, you know the ID of the event in question. So there's no difference between referencing this.eventId() and just typing the number 24. Using "this" only matters when you don't know which event might be running the code (which might be true for you, but you didn't say it) 😉
it's this:
$gameMap._events[this._eventId]._x;

or $gameMap.event(this._eventId).x, but basicly it's the same, but looks more nice.
It is better coding habits to get used to using accessor functions when provided, instead of accessing member variables directly. So all of the above works with the engine as written, but the most correct way to do it is $gameMap.event(this.eventId()).x
Actually, it is. As far as you described in your request, you know the ID of the event in question ... (which might be true for you, but you didn't say it) 😉

I thought that was implied by my pseudocode which used the word "self", but I appreciate I could've been clearer.
I understand what you're getting at - it just confused the issue when you said explicitly "this is a script within event #24" as opposed to "this script can be called by different events" or something.

But it's all good, you should be set 🙂
Um ...

Control Variables > Game Data > Character [This Event]'s > Map X
Control Variables > Game Data > Character [This Event]'s > Map Y

No need for script calls at all.


Note, if you are storing it into variables, you'd only want to do it (via either method) on a single event, or if multiple events, don't have them on parallel process. Otherwise one event will set them and another may override them before the first event actually uses them.
Um ...

Control Variables > Game Data > Character [This Event]'s > Map X
Control Variables > Game Data > Character [This Event]'s > Map Y

No need for script calls at all.


Note, if you are storing it into variables, you'd only want to do it (via either method) on a single event, or if multiple events, don't have them on parallel process. Otherwise one event will set them and another may override them before the first event actually uses them.

This prompts a related question.

Can parallel events literally run in parallel? Like even on different threads?

Or... Say you have 5 events, all with 1 page set to parallel. Do the pages queue up? Or do they literally all execute simultaneously?
Can parallel events literally run in parallel? Like even on different threads?
No
While modern computers usually have multiple cores, almost all programs only use one each (for several reasons) and let Windows distribute different background programs to different cores.
And that makes true parallel processing physically impossible for those programs.

If you follow the link to "bughunting" in my signature I placed some background info there on how the engine handles the so-called parallel processes.
They will run parallel in that one command in one event will be processed, then one command in the next event, and the next event and so on until all parallel events have had one command processed. Then the next command in each will be run, then the next command in each.

Things that might alter this is if an event has a command that has to wait for something, such as a wait command, a move route that has to wait for a step to be completed before taking the next step, etc. In that case, the event will not run its next command until the previous command has completed.

If an event has a Common Event command, it will be as if all the events in that common event were copied and pasted into the event that is calling it, so those commands will be run in turn, and after that the calling event's commands will resume.


Multiple autorun events will queue up, so if you have two of them, the one with the lowest event id will run first, and when it is disabled, the next one will run.


And that is more than you ever wanted to know about parallel events 😀
No
While modern computers usually have multiple cores, almost all programs only use one each (for several reasons) and let Windows distribute different background programs to different cores.
And that makes true parallel processing physically impossible for those programs.

If you follow the link to "bughunting" in my signature I placed some background info there on how the engine handles the so-called parallel processes.
Thanks a bunch, this was really useful to know.

They will run parallel in that one command in one event will be processed, then one command in the next event, and the next event and so on until all parallel events have had one command processed. Then the next command in each will be run, then the next command in each.
Ah OK - this is interesting.

I had assumed that if 2 parallel events run "at the same time", that in practice it would run each page of script one-after-another, not start processing one page whilst in the middle of another page.

Original thread: https://forums.rpgmakerweb.com/threads/asking-event-to-get-its-own-position.140693/