simulate parallel process type looping

I'm writing a script that takes into consideration a variable. If this variable is true, I want to perform some actions. If while performing these actions the variable is false, it halts performing. When I use any type of loop (loop do after an if conditional, while, etc) and the variable is true, it correctly performs the actions over and over but the rest of the game freezes. However, if I make this script in a common event with parallel process and a switch trigger, it works perfectly fine. The actions perform correctly over and over and the game doesn't freeze. But I'm trying to avoid having to use a common event. Any advice would be very much appreciated. Been trying to figure this one or for awhile.
Post your code.
you need to integrate the function into one of the existing default game loops and not create an exclusive loop yourself. Where to place the check depends on what exactly you want to do.
Ah, that makes so much sense, Andar. So basically any loop, obviously, created would halt the process of any other code but the reason parallel processes doesn't is because it's an existing loop that the game is already running in? So is there a normal update method to alias when it comes to doing something similar to this?
That's why we ask for details of what you want to do and what you specific code is.

The default loop has many parts, some looping more often than others and some only looping under specific conditions. As a result there is no single place where to put the update-function, but several options - and for choosing the best option the scripters (not me) need to know what exactly you want to do.
Ah, got ya. Well, it's not any one code in specific. It's any time I've ever tried to loop something that needs constant updating while keeping gameplay intact. For example one script I wrote while playing around with code trying to learn was while it is raining to have a custom made splash animation play on a random spot on the map to heighten the effect of it raining. I could get it to work perfectly fine except when the rain started and the splash animations started, I couldn't do anything else.

Original thread: https://forums.rpgmakerweb.com/threads/simulate-parallel-process-type-looping.37879/