Cleaning up my parallel processes

Hello!


I'm making some parallel processes to track the player's progress through various puzzles in my game, and I feel like they could probably be cleaned up a smidge, because they're producing crazy lag in playtesting. (For the record, I only experience significant lag while in rooms with parallels, so Occam's Razor would suggest it's not anything else causing the problem.)


I took a screenshot of a couple of my parallels:


https://www.dropbox.com/s/m3sj9iry8qiwmde/Screenshot%202016-06-02%2018.33.02.png?dl=0


https://www.dropbox.com/s/z3e9xdxxr6pkjov/Screenshot%202016-06-02%2018.32.38.png?dl=0


Just in case those don't work, I've copied the text from one of those parallel processes in the spoiler below:

Spoiler
Loop


  If #0003 is ON


    If #0004 is ON


      If #0005 is ON


        If #0006 is ON


          Fadeout Screen


          Change Transparency: ON


          Control Switches: #0002 = OFF


          Control Self Switch C = OFF


          Control Self Switch D = ON


          Break Loop


        Else


        End


      Else


      End


    Else


    End


  Else


  End


Repeat Above

Is there any way I can simplify these to reduce lag? I'm open to running the checks in some other way if that's needed to cut it, because playtesting this room is actually impossible due to the lag, and I really need to make sure this puzzle works. I'm a poster child noob when it comes to programming these processes, so I'm sure I can tighten this up somehow.


Thanks in advance!


PS: Just FYI the puzzle involves talking to people and giving them things, so this process is checking whether you've given four specific people their things or not. It then ends the puzzle sequence and moves you forward in the scenario once you've given things to those four people.
You don't need a parallel process at all for the puzzle you described (the give people objects puzzle). What you could do is pick a variable and each time you give someone their thing, add 1 to the variable. Then, set an autorun to run when the variable is set to 4, to do any processing you wish done when all 4 people have their objects. Just turn off the autorun with a self switch once it runs, else it will always run when the puzzle is over.
Also, loops are meaningless in a parallel process when the Loop command is at the start and the Repeat command is at the end.  Parallel process events repeat anyway, so you don't have to tell them to repeat.


And if it's something that you don't need to run/test 60 times a second, add a Wait 5 frames as the very first command (the 5 could be increased or decreased depending on how often the thing you're checking will change - if it's only going to change every few seconds use a larger number).  This (not having a forced wait) is probably one of the main reasons why parallel process events cause lag.


But the first thing to do is, as stated above, confirm that you actually NEED a parallel process event.  I've seen many cases where they're used and they don't need to be.
Thank you both! I tried both of these solutions across two of my parallel-process puzzles, and they both work wonderfully. No more lag!


This will help me a lot in future puzzle-making endeavors, too.

Original thread: https://forums.rpgmakerweb.com/threads/cleaning-up-my-parallel-processes.62889/