Day-night-cycle and "Sleep until morning" issue

Hello!

I'm working on a new project and can't get the following issue fixed:
My project includes a day-night-cycle that lasts one hour (=one ingame day) as a common event. It works like "wait x frames, tint screen, wait x frames, tint screen" etc.
I also want to include a function to sleep until morning, so I turned the cycle switch off at the beginning of the sleeping process and turned it back on when sleeping is done.
Unfortunately the cycle event doesn't stop, so for example when I go to sleep at night, it's still night after waking up.

In short:
Is there a way to forcefully stop/restart a common event?
It's possible that you could add a switch to your sleep event (ex: Sleeping = ON). Then you could have a loop in your day/night cycle event that checks if Sleeping = ON, and if it is, end the day/night cycle event. At the end of your sleep event, you can have it start your day/night cycle event again.

Though you might want to post pictures of both events in full if you want a more specific answer 🙂
You don't want to stop the cycle, you want to override it.
and that only works if the time is dependent on variables, not on fixed waits.


basically: count minutes, if hour= 7 tint sunup, if hour= 12 tint noon etc.
and then your sleep until event simply sets the hour variable for the correct time/tint.
Unfortunately my RPG Maker is set to german, but the events themselves are pretty basic. I added some rough translations if needed.
For those pictures I copied both events and deleted all the other stuff that has nothing to do with the problem itself (mostly variables for daily statistics etc.).

I also tried some loop solutions after your advise, but so far nothing worked.

edit:Andars suggestion sounds promising. I'll try it out.
You don't want to stop the cycle, you want to override it.
and that only works if the time is dependent on variables, not on fixed waits.


basically: count minutes, if hour= 7 tint sunup, if hour= 12 tint noon etc.
and then your sleep until event simply sets the hour variable for the correct time/tint.

This is a better way to go about it.
That Common Event has a lot of problems - for example whenever you switch maps, CEs are restarted. So you want a small wait loop counting the time, not a fixed loop.

one game day = one real hour means one game minute is 150 frames

so basically

wait 150
control variable minutes +=1
if minutes >= 60 then hours +=1, minutes = 0
if hours = 7 tint 1
if hours = 12 tint 2
if hours = 18 tint 3
if hours >=24 then day +=1, hours = 0

or however you want to split the day
First of all: I made it work. Thanks for your advice, Andar and also thanks for your help, Wiffle!

I made a total of five common events:
-one event with a loop "wait one frame, Variable 'Frames Passed"+1"
-four events with conditional branches for "day", "dusk", "night" and "dawn", that trigger in steps of 54000 frames (including 999 frames for the smooth screen tinting) or 15 minutes.

The "day" common event is a bit more complex, but that's mostly due to statistics, so don't worry about that.
I already tested it (with less frames needed for each time of day) and it worked. I even used a conditional branch on the bed that prohibits sleeping when the frames counter is above 215001 just to be sure there's no issue with sleeping during the new day starts (thus two days ending at the same time).

I put this in here just for providing anyone with the same problem a solution.

Thanks again!
I put this in here just for providing anyone with the same problem a solution.
That way is unfortunately a rather bad solution.

Biggest problem is the loop inside a parallel in the first screenshot - a parallel is already looping by default and that loop/schleife command does nothing for the event.

Then counting every single frame is a bit much, you might cause more lag that way than everything else. you need to count with a small number of frames to prevent loosing time on a map change, but not every frame - depending on focus most people work with a wait (60) and counting real-time seconds. You don't need to count sixty times per second.
In your case the wait (150) from my second post would be enough and more fitting.


I strongly suggest you go read my second post above yours where I explained how to do everything in a single common event.

Original thread: https://forums.rpgmakerweb.com/threads/day-night-cycle-and-sleep-until-morning-issue.176589/