Problems restarting an event loop.

I am having trouble with one of the event loops in my game.

I'm using labels to create a loop. When a condition is true then the loop ends and the switch controlling that parallel process is turned off.

It works perfectly the first time however after another event restarts the loop it will process a show text command and nothing after that.

Easiest way to explain would be to demonstrate so here is a simple basic demo. All you have to do is talk to one event on the only map and you will quickly see the problem. The file size is under 40MB so it shouldn't take long to download.

http://www.filedropper.com/loopproblemdemo

Hope someone can take a look and help
Give me 15 minutes. I am on it. Please reply to this post so I will not double post myself. 😉
Best thing to do is posting screen shots, so I will give an answer with screen shots if you don't mind, so people in the future will benefit by finding this thread.
I also suggest you to inform people of plugins that might be involved.🙂

Since I get no reply fast enough, I edit this post to add some feedback.

You got an event that has a set Trigger to Action Button. You call a Common Event that calls other Common Events and you want this to partly run in parallel. As long as this is an action button event though, the part you want to be in parallel will not run in parallel.

Workaround:


Create another map event, without graphics.
Its first Event page must be set to nothing (idle).
Now you will need to make a second Event Page.
Set both Event Pages as Trigger: Parallel
You can make as many Event Pages as you might need.

Add a wait(10) Event command on all pages and on every every parallel event, on every page you make from now on, to make the parallel events more lightweight. Parallel Events run 60 times per second. Such speed is not needed thus you can make a small delay that will make significant change to performance. The wait(10) Event command will really save you a lot of CPU resources.

Second Event Page overrides (meaning Second Page runs ignoring the first) if all its Conditions are met. If no condition is met at all, the first page runs if it has no conditions. That's why we set that page to Idle. You might need this to stop at a point, right? A third Event Page works the same way and so on.

Name a variable named FlowControl.
Use Control Variables in your eventing logic to set different values in FlowControl variable. FlowControl variable will determine if first or second or third and so on Event Page will run. A Common Event can just change FlowControl values, and the parallel event will call the Common Event you need to run in parallel! In those Common Events you might need to further change the variable values to trigger other Event Pages of the parallel event 😉

If you plan this better you might not even need labels, since you can loop by controlling a few variables, between events. It is somewhat advanced, but it is possible and more neat. Just saying. 😉
So, why avoid Labels? Why do I suggest you that?
For your reference, eventing is LIKE programming, but really significant more simple. Same principles apply though.
Label jumping is the equivalent of the GOTO command.
Check this out. 😉
https://en.wikipedia.org/wiki/Spaghetti_code

The third page of this article shows a good example why not.
https://craftofcoding.files.wordpress.com/2013/10/lore_spaghetti.pdf

I really care for you to learn WHY. If you keep using labels, you might even get yourself in a state that eventing will be so complex you might find it hard to change and when asking for help, people will just give up by seeing lots of label jumps.
I had somewhat hard time to understand how your simple demo works. I wanted though to understand it so I could give you a good idea on what is wrong there.
If you need anything to clarify, don't hesitate. All of us here will do our best.
Thanks for your reply.

I think I understand what you mean by flow control. Divide my entire loop into smaller sections controlled by a single variable so that I can easily restart the loop when needed.

I want the player to be able to move and change maps, that is why it has to be a common event. When I put a wait command inside a common event it acts like an autorun preventing the player from moving.

I also do not want it to run and complete the event instantly, that is why I need to have a wait command.

Even after I put the wait part of my CE into a different event and got rid of all my label jumps it still will perform as I want the first time and then the second time it will not complete the chain.

Spoiler: Screenshot explaining chain and where problem occurs

If I remove the parallel event the system works without a problem, both times.

All the problems seem to be caused by having a switch being flipped on and off to control a parallel event.

If CE had more ways to control how they are triggered I could create a flow control variable and use that to manage the chain.
"I also do not want it to run and complete the event instantly, that is why I need to have a wait command."
Extra waiting commands do the trick here.

You can set a whole common event to do stuff inside a conditional branch, thus make it possible to even have more control, without involving Common Event conditions.

Or make Common Events just work without any conditions, then make the whole logic inside map event.
Well by making the battle event be a permanently running parallel event with everything I need inside a conditional event that is only switched on when battle is actually happening, the problem has been resolved.

I wanted to avoid having a parallel event that is always running since I want to increase performance.

I;m still confused why switching an event on and off wouldnt function properly the second time it runs through. If it can do it once why not twice?

Or make Common Events just work without any conditions, then make the whole logic inside map event.

I tried to look for ways to activate event pages from a CE but couldn't find it. I think I would have to use yanfly's mod for that.

Original thread: https://forums.rpgmakerweb.com/threads/problems-restarting-an-event-loop.94081/