EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
588
Reaction score
375
First Language
English
Primarily Uses
RMMV
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?
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
1,249
Reaction score
726
First Language
Poland
Primarily Uses
RMMV
$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.
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
588
Reaction score
375
First Language
English
Primarily Uses
RMMV
$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;
 
Last edited:

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
1,249
Reaction score
726
First Language
Poland
Primarily Uses
RMMV
or $gameMap.event(this._eventId).x, but basicly it's the same, but looks more nice.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,261
Reaction score
1,216
First Language
English
Primarily Uses
RMMV
$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) :wink:
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
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
588
Reaction score
375
First Language
English
Primarily Uses
RMMV
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) :wink:

I thought that was implied by my pseudocode which used the word "self", but I appreciate I could've been clearer.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,261
Reaction score
1,216
First Language
English
Primarily Uses
RMMV
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 :smile:
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,728
Reaction score
15,308
First Language
English
Primarily Uses
RMMV
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.
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
588
Reaction score
375
First Language
English
Primarily Uses
RMMV
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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,948
Reaction score
8,615
First Language
German
Primarily Uses
RMMV
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.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,728
Reaction score
15,308
First Language
English
Primarily Uses
RMMV
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 :D
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
588
Reaction score
375
First Language
English
Primarily Uses
RMMV
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.
 

Latest Threads

Latest Profile Posts

My home state baseball team is going back to the World Series for the first time since 1999. I remember when they went in 1995 and won, that was like the best day of my life. (I'm a huge baseball fan and yes I'm talking about the Braves).
FL Studio is a huge step up from LMMS but I'm having such a tough time with it D:<
The new Dune movie reminds me of the game Dune 2 made by Westwood. A quality product on its own, but extremely disloyal to its source of inspiration.
Terrible Writing Advice, you've done it again.
1635026211997.png

Forum statistics

Threads
116,038
Messages
1,095,210
Members
151,384
Latest member
Boomy1234
Top