EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
609
Reaction score
396
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,320
Reaction score
787
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
609
Reaction score
396
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,320
Reaction score
787
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,804
Reaction score
1,642
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
609
Reaction score
396
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,804
Reaction score
1,642
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,178
Reaction score
15,543
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
609
Reaction score
396
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,341
Reaction score
8,762
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,178
Reaction score
15,543
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
609
Reaction score
396
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 Posts

Latest Profile Posts

My new 49" monitor has been dispatched from the warehouse. Will it arrive tomorrow? The day after? I love that we can track packages now, even if it does only tell me when it's left that end and when it's arrived at the local centre. As long as it doesn't end up in Melbourne again, which has happened before ...
My friend's doing a surprise stream of my game Origin Hunt on Twitch here ! Feel free to stop by :yhappy:
Me, designing it a long time ago: Having an optional boss fight as a random chance to trigger when you fish in a certain spot with a certain type of bait is fun! Cool idea!
Me, trying to playtest everything again: oh god just let me see the boss, my bag is so full of fish!
both love and pain have no boundaries
Happy Saint Nicholas Day! May there nice stuff in your shoes when you wake up!

Forum statistics

Threads
117,218
Messages
1,105,588
Members
153,367
Latest member
icemar
Top