Day/Night Cycle Timer Keeps Resetting

hello! i've recently managed to make a day/night cycle system for my game using only eventing! however, there is one problem involved. i put a timer to be able to see whether or not the time continues like normal. the day/night cycle continues through out all maps, but when i go to a new map, the timer seems to reset! so if it's one minute into the afternoon and the player goes to another map, the timer will start again at two minutes! it won't be good if a player is waiting for a nightfall and is forced to wait in the same map the entire time. here's the common event that i'm using. the "inside" switch is for indoor areas, where the lighting and music are not needed.
Spoiler: common event
◆If:D&NActivate is ON
◆If:inside is OFF
◆If:Morning is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:Town1 (90, 120, 0)
◆Tint Screen:(0,0,0,0), 60 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0023 Afternoon = ON
◆Control Switches:#0022 Morning = OFF
◆
:End
◆If:Afternoon is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:Field2 (90, 110, 0)
◆Tint Screen:(68,-34,-34,0), 60 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0024 Night = ON
◆Control Switches:#0023 Afternoon = OFF
◆
:End
◆If:Night is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:Theme2 (90, 100, 0)
◆Tint Screen:(-68,-68,0,68), 60 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0022 Morning = ON
◆Control Switches:#0024 Night = OFF
◆
:End
◆
:End
◆If:inside is ON
◆If:Morning is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:None
◆Tint Screen:(0,0,0,0), 1 frame
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0023 Afternoon = ON
◆Control Switches:#0022 Morning = OFF
◆
:End
◆If:Afternoon is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:None
◆Tint Screen:(0,0,0,0), 1 frame
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0024 Night = ON
◆Control Switches:#0023 Afternoon = OFF
◆
:End
◆If:Night is ON
◆Control Timer:Start, 2 min 0 sec
◆Play BGM:None
◆Tint Screen:(0,0,0,0), 1 frame
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Wait:720 frames
◆Control Switches:#0022 Morning = ON
◆Control Switches:#0024 Night = OFF
◆
:End
◆
:End
◆
:End
does anyone have a tips to make it so that the timer doesn't reset when switching maps?
when i go to a new map, the timer seems to reset!
When you change maps, any parallel common events restart from the beginning. That reveals a few flaws in your event:
- Simply issuing the Control Timer command without a Conditional Branch to see if it's already running

- All of those Wait commands strung together mean nothing when the event resets.

So, theoretically, if the player kept changing maps frequently enough, the time in your game would never advance.

A better method is to have a shorter Wait time which decrements or increments a variable - that variable's value will persist across map changes, so even if the Wait time resets, it's still incrementing the same thing.

This is my sample time system - you may not care about minutes, hours, and days, but it shows what I was just describing.

1721323472349.png


(the bottom is cut off but there's nothing there, just all the branches closing)
control timer mostly reset, some can use it persistent, but still, common event
recalling or by switch still resets it.

the way ATT_Turan describe is also like what most people do to make
an event day/night system as well for a timer that keeps updating,
and doesn't reset, so it's also much saver to do that way.

so I have no idea why you use so manu wait frames as you couldn't also
simplify with SRD_WaitOptions plugin, but a timer? no that's horrible.

so use ATT_Turan example, change 60 to 30 or 120 to wait longer for the min
part till it updates, what works best for you.
When you change maps, any parallel common events restart from the beginning. That reveals a few flaws in your event:
- Simply issuing the Control Timer command without a Conditional Branch to see if it's already running

- All of those Wait commands strung together mean nothing when the event resets.

So, theoretically, if the player kept changing maps frequently enough, the time in your game would never advance.

A better method is to have a shorter Wait time which decrements or increments a variable - that variable's value will persist across map changes, so even if the Wait time resets, it's still incrementing the same thing.

This is my sample time system - you may not care about minutes, hours, and days, but it shows what I was just describing.

View attachment 311830

(the bottom is cut off but there's nothing there, just all the branches closing)

i tried out what you suggested, and it worked! the wait time continues normally, even if the map is changed. thanks a lot! i admit, it's much better this way, since i'll have to extend the wait time to 40 minutes lol. i should get into the habit of using variables more often. thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/day-night-cycle-timer-keeps-resetting.170419/