Timer makes me crazy

Hello, I had a bit special idea for a game. My "hero" is a man with an alcoholic problem. If he is not drunk anymore, the game would finish. So I have a timer over the game. It starts at 40 minutes. So the plan is to let it go down, and if he drink beer increase to 40 minutes again. But always if i change the map, like walking into a house, the timer start again to 40 minutes.

I did it into an common event. The event is as a file online. By the way the code is german, but think that should not be the problem 😉


The Version is MZ.
Thanks in advance
Try using this Visual Timer Plugin
i try changing map and the timer did not reset.

hope this help.
The timer does not change by default when you change maps or even if you enter battles, so there has to be something wrong with your Common Event.

By the way the code is german, but think that should not be the problem 😉

Eh, sorry, but following anyone elses thought process behind eventing is hard enough as-is, it becomes even worse when it's in a language you don't know very well. I think that there's a bunch of switches and a loop there, if I understand it well enough? What's the event trigger? I guess it's a Parallel event? Well, can't really see anything there that would reset the timer to default, if it happens on transfer, then check the transfer events or any Parallel events you might have on the map.

By the way, I will leave this here, might be useful to you if you need to overhaul the system:

This script call will store the remaining time in the Timer to a variable with ID 3 (in frames ofc):

$gameVariables.setValue(3, $gameTimer._frames);

Then later you can start the timer again with this script call:

$gameTimer.start($gameVariables.value(3));

It will start the timer again right where it left off (change the ID of the variable to whatever variable you will end up using of course).
While it's fairly obvious in this case that you're using a Parallel event, in future I'd recommend including the event trigger (and, for map events, conditions/pages) in your screenshots. 🙂

Some notes on how the engine handles Parallel events:
  • All events (including active common events) are cleared when the map changes. Autorun/Parallel common events then get reactivated if appropriate for the new map. Note that an event is also cleared when it changes page (or, for Autorun/Parallel common events, when its switch changes value).

  • Parallel events each have their own interpreter, so when they get cleared, their interpreter is removed and they stop immediately. Other event triggers run through a persistent interpreter (map or battle), thus do not get interrupted on map change.

  • Parallel (and Autorun) events trigger every frame they are not already running, making them ideal for looped processes, e.g. checking every X frames to see if the protagonist is sober yet.
I'm guessing what you're seeing is a Parallel event restarting when you change maps. 😴

You have an event to turn on this common event's switch, right? I'd suggest starting the timer in that event instead, e.g.
Spoiler: Starting event
Code:
◆Comment:Initialise timer
◆Control Timer:Start, 4 min 0 sec
◆Comment:Start the common event
◆Control Switches:#0001 drunk = ON
Spoiler: Parallel event
Code:
◆Comment:Check timer
◆If:Timer ≤ 0 min 0 sec
  ◆Comment:Time up!
  ◆
:Else
  ◆If:Timer ≤ 2 min 0 sec
    ◆Comment:0~2 mins left!
    ◆
  :Else
    ◆Comment:2~4 mins left!
    ◆
  :End
  ◆
:End
◆Comment:Wait a bit before checking again
◆Wait:60 frames
😤

Original thread: https://forums.rpgmakerweb.com/threads/timer-makes-me-crazy.128433/