EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
608
Reaction score
395
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,305
Reaction score
768
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
608
Reaction score
395
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,305
Reaction score
768
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,706
Reaction score
1,590
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
608
Reaction score
395
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,706
Reaction score
1,590
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
44,083
Reaction score
15,499
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
608
Reaction score
395
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
34,258
Reaction score
8,713
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
44,083
Reaction score
15,499
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
608
Reaction score
395
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

Working on my first ideas for a tileset... I really don't know if anyone would like or even want my style.

k5a4BHk.png
Plus-size sprite continues! Front and back views done, or at least mostly there depending on if there's any more work you all think she needs. Once I get her done I can get working on her masculine counterpart:
PlusTest-03.gif
My game is basically turning into a 2 on 2 fighting game disguised as an rpg lol. here's eveyone doing their own intro in battle.
Sizzle sizzle sizzle...
zbf1dCZ.gif
Sharing my past was a mistake. Will delete the post when I get access to a working internet connection again.

Forum statistics

Threads
116,987
Messages
1,103,547
Members
152,856
Latest member
peachdelta
Top