Could having Common Events turning switches ON/OFF be a of cause Lag ?

I use CE to turn ON/OFF switches for my Night and Day Shift, now I know they loop, which means they would constantly turn ON a switch over a period of time. Now I was wondering if this could be a cause of Lag if you do that with like 10-20 Switches at the same time ?

Also if I add a loop with just a 'wait' function in it that plays parallel, could that also be a cause of Lag ?
The short answer is: Yes.

Having too many Common Events running in Parallel can cause severe lags on your game. It's a good practice to use switches to turn them On/Off and call them only when strictly necessary.

What are you planning to do exactly? A night/day system like in Breath of Fire I and II?
The only time Common Events should be a cause of lag are a combination of the following:
-You're running too many parallel events at once
-Your parallel events run too much stuff without any or enough wait time between loops
-Your computer might be heavily outdated?

But using a Common Event to just turn some Switches alone shouldn't be causing lag.
OPs described Scenario will not Lag, even if its a hundred.
Therfor no change would be needed even if there are more elegant ways like an extra condition
so the switch is turned on or off only one time when realy needed and not all the time again and again.
But that is only needed if you change graphic of an Actor, or tint the Screen, Play Music, or other Event commands, that could cause instant lag with OPs setup, or lag as soon something gets added which needs some performance reserves. But not with Switches, those do not realy matter, but it would be a good practice.

You could show Pictures of your Eventcode, else we can just guess and maybe we can suggest some things.

Edit:
You can have hundrets of Conditional Branches in a Parallel Event without Lag.
And manipulating hundrets of Switches and Variables at the same Time.
But one Parallel Event that is Changing Actor Graphic all the Time, will cause direct Lag.
Turning on/off 20 switches at a time will not cause lag. Having a parallel event running continuously with a Wait will not cause lag (in fact, adding a Wait is a way to remove lag caused by a parallel event).

Are you asking because you're just curious, or do you have lag and are trying to work out the cause? If you have lag, it could be another event (or common event) that's becoming active because of the switches you're turning on/off.
@Shaz Mostly it has just been switches I used to turn ON/OFF events that happens over a Day-cycle but with the latest CE I wanted to add a Sun when it rises as well as it dawns.
So far I do have dips from 60fps to 30-40fps every 30sec. but I'm sure that's the result from me changing rigs, my previous rig didn't had that issue.

@Milennin I moved from a Gaming Rig to a Mac, for production its way better but of course its gpu sucks, making play testing hard to figure if only I will have this issues or if what I got is actually severe. I tended to reach the limits of the engine quite easy in the past, that's why I'm way more cautious about it now.

@CleanWater Its more like an evolution form an Harvest Moon Day/Night cycle.

@Bex See attached files, that's gonna be a cluster F XD Its a Day/Night cycle with an Active showed clock that shows the Time, Day and Date, I use 12Months with 30Days as well as 4 Seasons, it controls on what date how my Trees look like, if there will be fallen leaves, snow or blooming flowers, People will be seen at specific times as well as the Color tone of the day.
The last thing I wanted to add now was a Sun that rises and dawns but that should also adjust with the season, like Sommer having longer days and winter shorter (Thou only spring has been done for that one yet)

EDIT: Oh yeah it also controls stop lights and react to jaywalking, that stuff has been connected with region tags.
1) the control switch command itself has absolutely no direct effect on any lag ever and never will have one.

2) what may have an effect is the indirect result of the switch. if the switch activates or changes a parallel process, then that WILL have an effect on lag - always. Sometimes the effect might be small if the parallel process has a good design (as opposed to bad parallel process designs that cause lagging hell), but it will always be there.

3) due to the effects of 2 it is a very bad decision to chain parallel events through switches. There is a reason why everyone says that all cutscenes should be controlled by a single event that remotely controls placeholder events on action button and without any commands inside.

whenever you have a structure where one parallel process is watching for a switch controlled by another parallel process, you should try to rewrite both in a way that the control switch command in the primary parallel process is replaced with direct remote commands to the other parallel process events, removing that second parallel process completely.
this will help you a lot with bughunting as it will make your events much better readable.
in the 2nd image, if minutes = 60, and if hours = 24 should also
be changes to >= 60 and >= 24 ( equal or higher than), which is
fail safe in case it might lag and jump to 61 and higher and 25 and higher,
and never reset to 0 otherwise to add an hour or add a day.

but some things should be rewritten like Andar said to combine them.
You could also try increasing your game's image cache size to see if that helps. That can be done via the Community_Basic plugin (included by default in new projects).
[Edit: whoops, that applies to MV but this thread is about MZ.]
Spoiler: explanation
Changing a switch or variable tells the map to refresh itself this frame, which includes checking/updating event pages. If an event's page changes, it'll load the new page's image. If that image isn't already in memory, loading it from disk might induce "lag".

By default RMMV has a relatively small image cache size (10 MPix) so if you're using a lot of different/large images simultaneously then this can have a significant impact.

Might be worth adding a Wait into Common Event 15 (screenshot 1) since it doesn't look like that needs to run every frame? Remember that all Parallel events (including common ones) restart when the map changes.

Also, be careful with Labels, e.g. at the top of Common Event 2 (screenshot 11). Nothing bad about them per se, but they make it easy to end up with infinite loops if you're not careful.
@caethyril Okay I did that with event15, where do I find that Community_Basic plugin ? its not inside the Js/Plugin Folder ?

@ShadowDragon Right, will do, thanks 😀
@Andar
1. That's reassuring to know thanks.
2. Yeah I noticed that, it happens in my game every time the stop light changes color.
3. You mean getting the 2nd image Integrated into one of my existing CE ? To be honest I'm still a noob when it comes to eventing, but I will keep that in mind, thank you.
You mean getting the 2nd image Integrated into one of my existing CE
no, I had not specifically targeted any part after a qucik check of what you had done.

I mentioned it as a general design principle that can apply to multiple of your events, and that the solution may or may not be the alternatives I mentioned.

you need to check where you can apply it for yourself, because there are too many variants.

and the worst thing you can do in all cases is slavishly applying any internet tip to everything, especially if you do not understand what that tip really does.
you cannot program (not even events) if you don't understand what you're doing.
and you cannot learn that if you just slavishly copy without thinking.
no, I had not specifically targeted any part after a qucik check of what you had done.

I mentioned it as a general design principle that can apply to multiple of your events, and that the solution may or may not be the alternatives I mentioned.

you need to check where you can apply it for yourself, because there are too many variants.

and the worst thing you can do in all cases is slavishly applying any internet tip to everything, especially if you do not understand what that tip really does.
you cannot program (not even events) if you don't understand what you're doing.
and you cannot learn that if you just slavishly copy without thinking.

Don't misunderstand, I didn't put my whole eventing out for others to fix it, I did so no one needs to speculate about what I did. By saying that Im a noob means I'm new at it, not that I'm dumb at it. What I did, I understand, otherwise it would be pointless to continue with what I plan to do in my Game.

But okay, I get what you mean and thank you for the advice and insight you gave me, it's much appreciated.
Your Event Setup looks like it will drain most of your Performance reserves and could be the cause its not running well on your Mac PC.

For example: If Hour is 14 you are Showing a Picture all the Time (If that Picture belongs to the always running Common Event?).
Also you are doing the Tint Screen all the Time, aswell as other stuff.

2 things i could thing of, a rewrite of the whole System, or a very simple Fix to the existing one.

For example you got:

If Var Hour 14 do Tint Screen.

we could do:

If Var "Hour" is not Equal to Variable "Bob" do
control var bob set to var hour
than do
your code as it is
If Var Hour 14 do Tint Screen.
If Var Hour 15 do Tint Screen.
If Var Hour 16 do Tint Screen.
If Var Hour 17 do Tint Screen.
end

This way it runs only one time each time 1 Hour has passed.
Else it would tint the screen up to 60 times per second or with a wait less often but
still even more as needed.

Or i missinterpreted the Pictures because the Top Part with the Common Event Page settings was cut off and not shown on some of the Pictures, so i had to guess XD.
But thanks for showing the Pictures, they helped alot identifieing the possible cause for your performance Problems
where do I find that Community_Basic plugin ? its not inside the Js/Plugin Folder ?
Whoops, sorry! I was thinking of MV. MZ doesn't implement a limit for its image cache, so that doesn't apply in your case. I'll correct my previous post. 👋
Whoops, sorry! I was thinking of MV. MZ doesn't implement a limit for its image cache, so that doesn't apply in your case. I'll correct my previous post. 👋
Ah I See, no Problem thanks anyway 😀

EDIT: @Bex I think I go with the simple fix in that case XD, thou I don't understand completely what you mean, so instead of 'equal or greater' you mean I should just use 'equal' to that time ?
If yes, then that's not an option in that case, because my game will include side gigs that may jump the time forward by 3-4 hours etc, thus its possible it would not hit that specific time.

Also I gotta Thank you for spending your time to help me out once again, so the very least I can do is show what I did if I'm asked for it 🙂

2. EDIT: I was also wondering if just putting a Loop with a wait in it could solve such issues ? That's why I also asked about it previously if that could cause any lag. In which Shaz said, it would be actually beneficial, so I was wondering if I could just add a loop in it instead (The one with tone).

3. EDIT: Oh yeah also, the upper parts from the images I posted are all complete, some are cut off at the end but this were really just the ends of it, nothing new added
My English isnt the best not sure how else to explain.

If Var "Hour" is not Equal to Variable "Bob" do
control var bob set to var hour
than do
your code as it is

end

To your other Question:
A Parallel Event is allready Looping, so i guess no extra Loop needed, or i miss understand.
Or that would just not work.
My English isnt the best not sure how else to explain.

If Var "Hour" is not Equal to Variable "Bob" do
control var bob set to var hour
than do
your code as it is

end

To your other Question:
A Parallel Event is allready Looping, so i guess no extra Loop needed, or i miss understand.
Or that would just not work.
Yeah don't sweat it, its not your fault I'm rather dense sometimes 😅
But I got it 🙂

Nope, wait I'm gonna make an example.
Bildschirmfoto 2022-08-06 um 09.52.30 AM.png
It looks like that could work in your Setup.

I often structure my Parallel Event in a Way that it Checks different things in the Game and than it activates the others only when needed, locking the
Interpretor inside such a Loop would cause me trouble. But iam amazed of this unusual but seemingly working solution of yours. It does work, does it?
I understand what you try to tell me, and I think at some point I might gonna change that whole system, when I'm actually better in it. At that point I might just do what you told me, its definitely more sound. But yeah, for now this little trick seems to work 🙂
Thanks again

Original thread: https://forums.rpgmakerweb.com/threads/could-having-common-events-turning-switches-on-off-be-a-of-cause-lag.150103/