A problem with a loop event set up for a timer

Does anyone know why when I set up a loop that works like:


loop


wait 60


set variable second -1


if second =or< 0


set second = 60


set minute -1


if minute =or< 0


run common event clock out


end loop


And in my common event I have set up a screen fade out, I change the clock back to 10 minutes and enter a text message about the timer had run out, then I use a script command to switch parties in tsukihime's party manager, and then fade back in the screen.


However when I test, the time reaches 0 and the screen fades out, the text message runs but none of the variable changes are made and the screen stays black and the party switch doesn't happen.


When I call the same common event using a button event I set up it works fine, when I use a menu option to call the common event I set up in yanfly's menu manager it also works fine.


I think it has something to do with the fact it is in a loop, but I have tried break loop commands and it doesn't change anything.


Any ideas?  If you need more info, Screenshots are below.


Thanks for any advice or help!

Spoiler
ClockCommonEvent.PNGClockCommonEvent2.PNGClockCommonEventTest1.PNGClockCommonEventTest2.PNG
Please post screenshots of your events - there are several things that might have happened, but we can't tell because you omitted several important informations on that text writeup.


Posting a screenshot is usually faster and easier than retyping your event contents, and it is always complete (there are a lot of people who are missing half their event, including their errors, when typing an event that way).
I added screenshots to the original post.
several problems visible at first glance:


1) parallel processes automatically loop - placing an additional loop command inside the parallel process will always throw off timing, remove that loop.


2) where is the initial setting for the minute? if there is no other command, the event will start with minute=0


3) hhow and where do you check for the changes? please include the event or plugin that displays your time.
The time works normally, I initialize the minutes and seconds when I turn on the switch on initial load into the map.  The clock counts down normally and successfully all the way to 0 minutes and 1 seconds and then it goes to the common event, where the screen fades out, it plays the message about "player \v[12] your turn will begin when you accept" and then nothing, the screen stays black, the variables don't get updated to 10 minutes, and the variabale for actual party doesn't get set to 2, the screen never is faded in.


This same common event works normally for a manual call of the common event through a menu option or when I create an event that is activated by the player.


That is the problem, not the timer counting down.
you don't understand - you have to remove the loop, because that causes timing problems that are absolutely not neccessary, and I strongly suspect that those timing problems are part of the cause of your problem. Especially as such a loop can disable other parts of the game sequence.


Because any common event can only be called once per frame, and the loop can force multiple calls in the same frame - besides a lot of other problems.


Please remove the loop from your main event and then test again if that is enough to solve your problem, or if you have to continue searching for other problems.


I also suggest you follow the link to the bughunting tutorial in my signature to understand why all errors have to be solved, no matter if they do something at the moment or not.
I removed the loop, the exact same results.


Edit:


I turned the second end of turn common event into a parallel as well with a switch.

Spoiler
ClockCommonEvent5.PNGClockCommonEvent6.PNG





Tested and works correctly now.
Please update the screenshots to the current version, and please add text to the inner showtext for showing the variable values.


And give full screenshots for the second common event - we don't need repeating player messages, but we need to see how it ends
If you get the same (unwanted) results when you remove the loop, why did you mark your post as solving the problem?

Original thread: https://forums.rpgmakerweb.com/threads/a-problem-with-a-loop-event-set-up-for-a-timer.72124/