How to do a global event?

I'm trying to do an event that triggers everytime a variable hits 100. When this happen, a dialogue is displayed on map and battle. I want that this happens on everywhere on the game, kinda like a global event. I know I can do this putting the condition on every map, but that would be laborius and can interfere with other events. I suppose it has to do with the Common Events tab, but I can't figure out how.

What I'm doing is:

Common Event #1
Trigger: Parallel Process. Switch: MessageEvent1
Content:
If variable = 100
>MessageEvent2 = ON
Else
>MessageEvent2 = OFF

Common Event #2
Trigger: Automatic Process. Switch: MessageEvent2
Content:
(The dialogue displays)

I'm sure I'm doing it very wrong, because the event goes in cycle because the parallel process. But automatic process just freezes the game until the condition is on. Any advice?
I mean whatever event counts your variable should just activate a switch, the common event that happens whenever it's 100 should just be this I think:
1689229908083.png
But automatic process just freezes the game
that is the intention and the difference between parallel and autorun:
autoruns will always freeze everything else.

However this brings us to another important point:

don't chain autorun/parallels events by switches.
Place the commands for the text you want to display at the place where you turned on the switch instead.

For more detailed help we would need to see the entire events, including how the variable is counted.
I'm trying to do an event that triggers everytime a variable hits 100. When this happen, a dialogue is displayed on map and battle. I want that this happens on everywhere on the game, kinda like a global event. I know I can do this putting the condition on every map, but that would be laborius and can interfere with other events. I suppose it has to do with the Common Events tab, but I can't figure out how.

What I'm doing is:

Common Event #1
Trigger: Parallel Process. Switch: MessageEvent1
Content:
If variable = 100
>MessageEvent2 = ON
Else
>MessageEvent2 = OFF

Common Event #2
Trigger: Automatic Process. Switch: MessageEvent2
Content:
(The dialogue displays)

I'm sure I'm doing it very wrong, because the event goes in cycle because the parallel process. But automatic process just freezes the game until the condition is on. Any advice?
It looks to me like you've forgotten to change the variable value back to 0 when you turn the switch on. But also there's no reason you can't just put the dialogue into that conditional branch and save yourself a common event.
I don't really know your setup or the context of what you're trying to do, but personally, instead of having it run as a parallel process, I would set that common event to "Trigger: None". Then, in whichever place you increment your variable, I'd call the common event with the "Common Event" command under "Flow Control" on command page 1.

See, the check for the variable really only needs to happen whenever it updates, so that should be the only place the check runs. That way you don't have an unnecessary parallel process running at all times, which down the line could clog up your performance. It also saves you that one switch you'd need to spend for picking the parallel process option.
Whoops, yes I think I should be more specific.

Well this is the whole idea. I have this kind of "Sanity Meter" that increases in many situations. Interactive objects, skills, and scenes adds a value to this variable. My intention is that when this variable hits 100, a textbox appears to indicate that the character is "insane".
Then, in whichever place you increment your variable, I'd call the common event with the "Common Event" command under "Flow Control" on command page 1.

But that means I have to add it to every event that increase the value. Because many events do that, shouldn't be more convenient to have a global event that checks when the variable hits 100? So the textbox can appear at any moment.
make a relay system:
-one common event set to parallel, constantly scanning that variable for 100.
-on 100, put a switch on and drop that variable to 0.
-to that switch, set another common event that handles your banner.
You could do it that way, but I'd say you don't need any parallel activity at all for this.

I think it comes down to how you phrased your original request. Instead of thinking "how do I monitor this variable," alter how you change the variable.

So make a common event that increases the variable by one, then does the checking for it to be 100 and shows the text box and everything.

Then, every existing event that does Control Variable +1 for that variable, just change that to call your new common event instead. That will increment the variable and check it at the same time.
If you're really lazy and don't want to do the common event you can use CT_Bolt's plugin which lets you run code whenever a variable is changed

You could put something like
if($gameVariables.value(x)>=100){
$gameMessage.add("You are insane.");
}
make a relay system:
-one common event set to parallel, constantly scanning that variable for 100.
-on 100, put a switch on and drop that variable to 0.
-to that switch, set another common event that handles your banner.
Well that worked on me. But now that the variable is 0 after hitting 100, the variable indicator is shown empty. And that make it looks a bit illogical, because if you are in "Sanity Mode", it doesn't make sense for the meter to now be at 0 lol.

But I think its fine, I could hide it with a UI element.
But that means I have to add it to every event that increase the value. Because many events do that, shouldn't be more convenient to have a global event that checks when the variable hits 100? So the textbox can appear at any moment.

You already have to add a command to increase the value to all of those events anyway. Adding one more command to call the common event behind that isn't really that much more work.

On top of that, if the value increase is fixed across all instances (i.e. every event that updates the variable always increases it by 1), you could do what ATT_Turan said and write the value update directly into the common event.

Like, ultimately doing it as a parallel process works, so if you really want to stick to that, feel free to. But I think it's a good idea to develop healthy habits, and doing this in a way that's easier on the processing would be beneficial as a learning experience, so you'll tackle future endeavors with a similar mindset, and get familiar with the benefits of the "call common event" command.

Now if only the RMMV natively supported the "Call Event" command from back in the RM2K days... Luckily there is a plugin to restore that very valuable and useful feature.
Now if only the RMMV natively supported the "Call Event" command from back in the RM2K days... Luckily there is a plugin to restore that very valuable and useful feature.
What do you mean?
Screenshot 2023-07-13 162047.png
And that make it looks a bit illogical, because if you are in "Sanity Mode", it doesn't make sense for the meter to now be at 0 lol.
that should be doable with a simple common event.... like, the way it was always done: set it to parallel with a switch set to ON at the beginning of the game.
on var == 100, trigger the message and drop the switch.
one event, one condition.

ideally, all HUD-related events should be handled by a proper HUD system
Oh, no, not "call common event". "Call event". It allowed you to select a page from any other event on the same map and run it like it was a common event. It was great for doing stuff like having a set of events that are only marginally different, but still largely did the same thing, or to alleviate having to copy paste a bunch of teleporters if your TP area was larger than one tile. The functionality is reintroduced for RMMV through the YEP_CallEvent plugin.

Like earlier today, I used it to have a set of four NPCs that say a unique line depending on who you initiate with, but then all proceed into the same battle processing event + following cutscene. Without the plugin I would have had to copy that battle processing into each NPC separately (which would make doing alterations later really annoying) or waste one of my common event slots, or waste a switch on an autorun event. But this way I could just pack the battle processing + following cutscene into a separate event and call it from the NPCs.

The plugin version of this is actually "call event" on steroids, because it also lets you call events from OTHER maps. So I can have an empty map full of dummy events that are all filled with various small pieces of event code that reoccur all throughout the project and that a common event slot would probably be wasted on, and I can just call on them as pseudo common events.

This might be really boring for everyone else, but I love this! It's like it was made for me.
Ah. I see what you mean.

I just would think it's pretty trivial to use the Copy/Paste Event Page buttons for most of that. The last case, with mini events you don't want to waste common events on, that's reasonable...although are you really in danger of using up all the common event slots? 😉

Original thread: https://forums.rpgmakerweb.com/threads/how-to-do-a-global-event.159272/