How to create a temporary Parallel Process Event at the start

This seems like it would be easy, but it's giving me some problems.  

I have a parallel process event I want to run every time the player re-enters the game.  But I don't want it to loop.  

My initial way of dealing with this was I created a loop in my parallel process after the initial sequence that I did not want to loop.  That worked.  But it seems that creating a loop within a parallel process causes my game to lag unacceptably.  So I need to find a work around.  

Any suggestions? 
you need to switch from the non-looping parallel process to a different event page with the looping part of the parallel process after the one-time-sequence had been executed.


And no, you should never use the loop command inside a parrallel process unless you know exactly what you're doing and know how to prevent lag in that (which means that a loop command on a parallel process page is almost everytime wrong).


Edit:


Alternatively however you can part that into two events and have the first one erased after it was run, then it will run again once the player enters the same map again.


Depends on what exactly you want to be done.
you need to switch from the non-looping parallel process to a different event page with the looping part of the parallel process after the one-time-sequence had been executed.

Edit:

Alternatively however you can part that into two events and have the first one erased after it was run, then it will run again once the player enters the same map again.

Depends on what exactly you want to be done. 
I tried this.  But the problem is I didn't know of a way to turn the switch OFF when the player exists the game so the sequence will run again when the player re-enters the game.

Is there a temp.switch I don't know about?

Response to the Edit:

I tried erase event also.  The problem with that though is the event seems to stay erased unless the player leaves the map itself and then re-enters.  Exiting the game itself doesn't appear to reset it.  And I need the event to run each time the player re-enters the game on the same map.
so you mean like if I save right now and exit, then restart the game (so I'm still on that same map), the sequence should restart?


Hmm... probably use a switch, then go to the load script and add a line to switch off the switch ($game_switches[id] = false)
I would set it as a parallel process common event (assuming you want it to run regardless of which map you're on), conditioned by a switch. Turn the switch on initially if you want to run it when a new game is started. Then edit your DataManager.extract_save_contents method to turn the switch on - make it look like this:

Code:
  def self.extract_save_contents(contents)    $game_system        = contents[:system]    $game_timer         = contents[:timer]    $game_message       = contents[:message]    $game_switches      = contents[:switches]    $game_variables     = contents[:variables]    $game_self_switches = contents[:self_switches]    $game_actors        = contents[:actors]    $game_party         = contents[:party]    $game_troop         = contents[:troop]    $game_map           = contents[:map]    $game_player        = contents[:player]    $game_switches[id]  = true  end
And you're right - you should not have a loop encompassing the whole block of code inside a parallel process or autorun event, as they loop by default.
This worked perfectly.  

Thank you both for the help, appreciate it.  Especially for the added details on how and where to edit the script contents, else I would have probably messed this up.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-create-a-temporary-parallel-process-event-at-the-start.21461/