How can I get the ID of the current common event?

How can I get the ID of the current common event?

$gameVariables._data[100] = $dataCommonEvents[this._commonEventId];

It seems like this, but it doesn't work...
What do you mean by "current"? Multipulr common events can be run at once
What do you mean by "current"? Multipulr common events can be run at once
For example, I put it in common event 1, then the current is common event 1,so,$gameVariables._data[100] will be = 1
I think what @Oddball means is that the Maker doesn't have a preset way of tracking one 'current' common event, since they can be called at any time, and also may not be used in a game at all. When a common event runs, just have it load it's id into a variable. So make the first thing common event 1 does is load the number 1 into a variable.
You can't. Regular events' interpreters contain event IDs. But not common events.
If you call a common event, then the interpreter still stays the interpreter of the event that called it.
Parallel common events have their own interpreters, but the event ID doesn't get stored and will always return 0.
You can't. Regular events' interpreters contain event IDs. But not common events.
If you call a common event, then the interpreter still stays the interpreter of the event that called it.
Parallel common events have their own interpreters, but the event ID doesn't get stored and will always return 0.
If I use yep_picturecommonevent call a common event,then also returns 0?
Yes, it returns 0 too.
Yes, it returns 0 too.
So can I get any other data for the current common event? For example, name
Don't you think if that was a possibility, I'd mention it?
Alright then, the long version. There is no other way to find from the interpreter what kind of a common event it is except for comparing the list of commands to see if it checks out. But that is extremely inefficient, because if you have 100 lines in a common event (and not commands... Lines including comments, empty lines and other spammy lines, so it's not difficult at all to achieve), that's 100 ifs that need to be resolved per common event, which at 200 common events would be up to 20,000 ifs... Which is not a lot considering the CPU power, but it's not what you'd want in a game as it can lead to lags. It will be even slower especially if you intend to do it through the event's script command as that's an eval (eval is about 50000x slower than function execution).
So if you want to do that, I'd recommend you to use the control variables command as already suggested.
@aroha
try to think outside the box.

common events are always triggered from somewhere else, they NEVER happen on their own.
And YOU as the devveloper are the one that decides on when a common event should be triggered.
so you can have your own logic in the event that triggers the common event (either by calling it or by activating its switch).

If you're considering to have a lot of common events constantly running on parallel process then you should rework your logic structure - one of the basic rules for easy development and realistic bughunting is to have as few parallel processes as possible. Having more than two or three constantly running only works if they are rather simple, and in those cases you never need to identify them.


If our infos to you don't help, you need to describe to us what you want to do with those common events that you need to ID them, because that idea in itself speaks of bad programming logic or bad ideas.

EDIT-Addon:
Your biggest assumption is that there is a "current" common event, because there is no such thing directly - the main game loop doesn't work that way.
When do you need to know the ID? What do you want to achieve by knowing the ID?

The game will run your common event from start to finish before it actually moves on to the next process as the game processes stuff one at a time, so in essence, the "current" common event can only be determined inside that same common event itself. In that case, you would know exactly what the ID of that CE is, there would be no need to determine it.

and as Andar said, since CE's will always have a trigger before they run, you can just make the stuff that triggers the CE to do things like set a variable equal to the ID of the common event that you're gonna run (since you know what it is anyway).

Again, how to do this (or if its possible) would really depend on what you want to achieve as your end goal in the first place.
I can actually think of some times where I would have liked to know the number of a common event being called. Usually for a reason having to do with organization. It's really hard to explain, because the situations where you'd want to know it are super contrived and specific. I can't remember the why, otherwise I'd share it.

All I can say is it was a situation where I could have found another solution, but it would have been very involved, and the remedy was being able to know on the fly what common event was running, based off of the way I'd organized them.

However, like I said before, a simple solution is to set aside a variable for tracking it, and load that variable as the first line of any common event. It's not perfect, there are ways where it could produce a result you didn't want, but in general, it works.
It seems that I want to make a new variable for each common event to recognize it.
It seems that I want to make a new variable for each common event to recognize it.
no, that sounds as a bad idea as well.

please tell us what you want to achieve (ingame terms) instead of how you want to achieve it (programmer terms), then we might be able to guide you to a good solution.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-get-the-id-of-the-current-common-event.114098/