Preventing Timer = 0 Loop

I'm trying to do a little puzzle section where the player activates a switch to deploy a wood bridge over fire. They have a limited time to cross the bridge before it burns up, represented by a timer. If they fail, the room resets and they are teleported back to the start of the room.

The issue is that the event to control the timer never turns back on. When I set a player touch tile to restart the event, the timer sees itself being 0, and causes the teleportation endlessly. If I set the switch to create the bridge to restart the event, the timer hits 0, and the event locks up and doesn't work for the rest of the room.

I'm sure I'm missing a flag or a split path, but any help would be appreciated.
Hello PsychoFrost.

It seems that the issue is not on this event. Maybe on another.

Which event takes you to the said place?

Edit: Removed the link to my game tutorial on Itch.io at @MushroomCake28 request.
Hello PsychoFrost.

It seems that the issue is not on this event. Maybe on another.

Which event takes you to the said place?

If you don't mind, I suggest taking a look at my "Events" and "Switches" lessons, as it explains almost everything you need to know about it.

Here are the switches that activate the event, as well as the layout for an example.
So, if I understand it well, you have several switches for each bridge set, right?

Did you tried chaging the switch for the Parallel event, Fire Check, before the Transfer Player command?
if you want a more control over timer (as basic timer doesn't work really)
not on my end, is use SRD_TimerUpgrade, but you can best try to set
a parallel event for a variable timer (600 = 10 second)
and use a common event (or just that map if you need it), so teh setup
for that would be:

set variable x = 600 (10seconds)
if variable x < 0
set variable x = 0
the events you have on timer 0min, 0 seconds
else
variable x -= 1
end

this gives you more control, and work much better and smoother 🙂

small edit:
set variable is on the event where it starts, the condition branch (if variable)
as a timer goes in the seperate (like yours) just a slightly different 🙂

hope it works for you.
Alright, I'll try the improved timer plugin. I tried the parallel process suggested, but I think I have it setup incorrectly.

Thank you both for your help.
I think you simply need to look at (or show us) the touch tile that resets the event. You will need to turn off the parallel event (powered by switch Fire Check) while that touch event restarts the timer and then turns Fire Check back on.

If you have any issues with that, post a screenshot of that. I see no reason why you would need a plugin to make this work.
I think you simply need to look at (or show us) the touch tile that resets the event. You will need to turn off the parallel event (powered by switch Fire Check) while that touch event restarts the timer and then turns Fire Check back on.

If you have any issues with that, post a screenshot of that. I see no reason why you would need a plugin to make this work.
Here is the new parallel event suggested above. I'm not sure if I made it correctly.

Second screen is the activation switch, which creates the first bridge and starts the timer.
Here is the new parallel event suggested above. I'm not sure if I made it correctly.

Second screen is the activation switch, which creates the first bridge and starts the timer.

Psycho, just test it and see. If it works, you made it correctly. 😉

By the way, you did well to remember to "stop" the Timer.
Here is the new parallel event suggested above. I'm not sure if I made it correctly.
I'm confused by the beginning of event 3.

The first command you have is to set variable 42 to 600. The very next line checks for variable 42 to be equal to 0...how can that ever be true?

Since that's never true (as 600 does not equal 0), the else will be executed instead, which reduces variable 42 by 1.

Then, since you don't have any wait command or turn a switch off, the very next frame the event will run again and set variable 42 back to 600, then check it and reduce it to 599...then again the next frame...
I'm confused by the beginning of event 3.

The first command you have is to set variable 42 to 600. The very next line checks for variable 42 to be equal to 0...how can that ever be true?

Since that's never true (as 600 does not equal 0), the else will be executed instead, which reduces variable 42 by 1.

Then, since you don't have any wait command or turn a switch off, the very next frame the event will run again and set variable 42 back to 600, then check it and reduce it to 599...then again the next frame...
Correct. The parallel event was created in lieu of the timer issue. Every frame it checks to see if the starting number (600) is 0. If it isn't, it drops by 1 and checks again. Since it runs at 60 FPS, it will check for 10 in game seconds. When it eventually hits 0, the player has taken too much time and the room resets.

The issue with this event in testing is that it doesn't seem to be ticking down correctly. Once active, I waited for 40 seconds for it to hit 0, but it never did. Not sure what went wrong.
Can you switch position of the Teleport Event Command and the last command and see if that solves your problem?
I mean this 2 Lines of your first Picture, just change the order, its just a blind guess, but maybe:
testos123456789.png


Edit: Here i found an Error:

index.php

Every Frame you set the Variable Fire Esper to 600 than later on you subtract 1 so its 599.
And the code will repeat that endlessly. You need to change the structure of that code to work properly,
else it will be always 599.

One quick example:
If Fire esper is less than or equal to 0 than do Set Fire Esper to 600
else do if fire esper is 1 do "Set Var Fire Esper to 0 and do Your Timer Ends Stuff than do Fire check Switch Off"
else Substract 1 from Variable Fire Esper.
variable 42 = 600 = where the event should start.

the timer check if variable 42 <= 0 (NOT = 0) because this cannot be true
if the player gets lag, so check if its lower, if it is
variable 42 = 0.
and the rest of your event you had on the timer part.

it was a really simple switch you had to made if you read my small setup post correctly.

edit:
this is your time how it should look like.

the set variable to 600 is the event where you set the switch on.
Untitled-2.png
fireexper should be 0, not "juist gespeld" as it is from my side project,
so ignore that one 🙂 as it should be fire esper, so something went wrong.
Correct. The parallel event was created in lieu of the timer issue. Every frame it checks to see if the starting number (600) is 0. If it isn't, it drops by 1 and checks again. Since it runs at 60 FPS, it will check for 10 in game seconds. When it eventually hits 0, the player has taken too much time and the room resets.
That's not correct - did you read my post that you quoted?

The issue with this event in testing is that it doesn't seem to be ticking down correctly. Once active, I waited for 40 seconds for it to hit 0, but it never did. Not sure what went wrong.
I told you what's going wrong 😛

The first command in your event sets the variable to 600. That means every frame, every time that event runs, you make the variable be 600. Then you do all your checking, and it will always be 600 when you check it.

You need to set it to 600 someplace else and then you can check and count it down.

As a side note, you should almost never have a parallel event that simply runs like this. That's how events can create lag in games, by running every frame when they don't need to. If you only care about 600 going to 0, then don't decrement by 1 and check every frame - decrement by 10 and have a wait command of 10 at the end.

Or, since you're timing seconds, just set it to 6, decrement it by 1, and have a wait command of 60 frames to check every second.
Can you switch position of the Teleport Event Command and the last command and see if that solves your problem?
I mean this 2 Lines of your first Picture, just change the order, its just a blind guess, but maybe:
View attachment 244880

Edit: Here i found an Error:

index.php

Every Frame you set the Variable Fire Esper to 600 than later on you subtract 1 so its 599.
And the code will repeat that endlessly. You need to change the structure of that code to work properly,
else it will be always 599.

One quick example:
If Fire esper is less than or equal to 0 than do Set Fire Esper to 600
else do if fire esper is 1 do "Set Var Fire Esper to 0 and do Your Timer Ends Stuff than do Fire check Switch Off"
else Substract 1 from Variable Fire Esper.

I see what I did wrong on the parallel process. Sorry about that.

I've tested the corrected process, and it works exactly as needed. @ATT_Turan I will adjust the event as you suggested to reduce lag. Thank you everyone for all of your help.

Original thread: https://forums.rpgmakerweb.com/threads/preventing-timer-0-loop.152517/