Parallel Process in Common Event

Hello! I'm still not sure I understand Parallel process. I use them but I'm unsure on when it's too many or bad. (So far I haven't had any problems though)
I set up a Common Event that acts like an achievement checker that uses parallel. But if a Night and Day system is along with it, is that too much? (Two separate events in the Commons)

How do I make sure a parallel process is done correctly? What are some tips or things to keep in mind what not to do with Parallel?

Thanks to all who answer. You guys are awesome.
The most common way to keep common events in check is to add "wait commands" to them.
A parallel event executes its commands every frame (60 times per second).

So you would want to add a wait command of 1 second or more.
e.g. wait 60 frames.

Because I doubt that you need to check the achievements every frame right?

Other than that, I don't know since I rarely use Paralell events (I mostly use Autoruns).

Obviously you should try to limit the amount of Parallell events running at the same time, but
2 should be fine. Just give them a wait command so that they don't run every frame.
How do I make sure a parallel process is done correctly? What are some tips or things to keep in mind what not to do with Parallel?
Aside from what ScorchedGround already suggested (if doable for the feature you want to implement), I would suggest to avoid "writing" data in a parallel event, like setting variables and switches, but also changing party members, adding/removing items, etc., if that data is read somewhere else, like another event or a battle system.
"Reading" data in a parallel event is usually fine (the worst that could happen is that the data is outdated the moment the parallel events reads it), but writing data can "break" other events, if you are not careful.
For example, if you write values in Variable 1 inside a parallel event, and the same Variable is also used to determine the behaviour of an NPC in an event (let's say, with values 1, 2 and 3 for each behaviour), it could happen that the parallel event sets the Variable to 3 just after the other event changed it to 1... so you would normally expect the NPC to have "behaviour 1" (because of the normal event), while instead it shows "behaviour 3" because of the parallel event writing on the same Variable concurrently. And maybe the rest of the processing of the normal event is altered because of this.

So, try and perform only "read" operations inside a parallel event, and if you need to perform any "write" operation, just temporarily stop the parallel event and use another process (e.g. Autorun). This way you "enqueue" your write operations in the normal event sequencing, and you won't have concurrency issues.
Is "reading data" things like checking for if variable = 1, if true say message with another variable check to stop the variable from repeating?

Is writing actions perform events if true and reading just text that is read continuously in a loop but nothing happens unless conditions are met?

What's the cap on Common Events using Parallel? In case I happen to make more in the future?

Thanks for the answers you two. 🙂
You get what a "read" action is: you check the value of a given Variable/Switch or a state of a given object (e.g. "if Variable X = 2, do Y").

A "write" action happens when you alter the state of those objects, Variables/Switches, e.g. "Control Variable -> Set Variable X = 2". You are "writing" a new state in the Variable, in this case setting its value to 2.

I don't remember if there is a hard-cap on Parallel Events, but as ScorchedGround mentioned, you shouldn't really have more than 2-3 running at the same time. Performances may depend on many factors (e.g. complexity: a parallel event with just an "if statement" and a "show text" is not as heavy as a parallel event with 300 commands), but any parallel event adds some overhead to the execution, so you don't want to use too many.

If you can, consider organising your parallel events in a single parallel event with separate Call Common Events inside. So, instead of having 2 parallel events with "check X, and do something" and "check Y, and do something else", you might try:

Code:
Parallel Event
  Call Common Event: check X, and do something
  Call Common Event: check Y, and do something else
End Parallel Event

This way, you will have a single parallel event running, while the other Common Events will be performed on call.
i don't know how complex your common event for checking for achievements is.
But if you only check for certain variables or switches to be on, you should be fine.
As said before, I would recommend wait commands ranging from 60-180 frames, depending on its complexity.

But as you mentioned that you may or may not have a Day/Night System aswell, I would be cautious.
Having Day/Night systems as a parallel event can be very consuming, depending on its complexity.
If you start having performance issues, I would advise putting that one on a higher wait than normal.

In the end, it all depends on how much stuff you put into your parallel events as midgardsormr said.
So there is no hard number of parallel events you can have.
20 Lightly packed events with wait commands can run smoother than 3 events filled to the brim with commands and checks.
Yeah, I have a Day and Night system set up. I really want a lot of variety on what happens during the day. Like when the variable hour is greater than or equal to 24, all the variables reset.

Variables like, if an NPC gave a player an item. (I don't want the item repeating) Or a Switch that opens or closes a shop/building.

If there are for example, 100 or more variables listed under the Condition check that 24 hours has passed, is that bad? (I obviously don't have 100 or more lol)

I will go ahead and add waiting. I really appreciate the answers. I just don't want to spend hours into something that will be a waste of time in the end. I hope you don't mind if I have future questions. ^^;

Original thread: https://forums.rpgmakerweb.com/threads/parallel-process-in-common-event.132988/