Customizable Clock and Time (Day/Night cycle)

@slickdeath97 @KingHazeel here is a screenshot of an event that checks if it is time to rain.

index.php


using (18..32).include?($game_clock.phase) means checking if the current phase is greater than or equal to 18 and, at the same time, less than or equal to 32.

If you want to let it rain from 10PM to 2AM then you have to check if current phase is greater than or equal to 44 or less than or equal to 4.
@Heirukichi the img wont show.
@slickdeath97 even if you click the link in the attached files list?
@Heirukichi the second one shows up, but the first one doesn't no matter what i do. nvm it just showed up. i guess i had to refresh the page. By the way will the weather effects show up while i am in a building?
@Heirukichi will the weather effects show up while in a building?
The fact you can trigger weather effects based on the current in-game time does not change the way the engine handles weather effects. You have to manually add-remove them each time you enter/leave a building. You can use the same check on current clock phase, but you have to use it in each event that transfers the player outside, and you should add a Weather Effect command to set the weather to "None" each time you enter a building.
Was trying to turn off the tint changes in the script because I want to replace the game's default tint changes with shades from Victor's Light Effects script. So the first thing I did was set TINT_ON_CHANGES = false, however, this doesn't seem to make a difference. The tint still occurs when testing the game.

EDIT: Of course, I could just set all the tint values to 0, so...not a big deal I guess. XD
EDIT: Of course, I could just set all the tint values to 0, so...not a big deal I guess.
That wouldn't work because your screen would still be updated to the normal tone. However, since this was caused by a bug, I fixed the code so that screen tint is no longer applied when TINT_ON_CHANGES is set to false.

You can find the code following the link in my first post. Thank you for your report.
Something else I noticed and I thought I'd point out: If you add time to the clock it won't exceed 23 hours...which is to say, rather than 23 + 8 being equal to 7:00 AM. It's still 11:00 PM. No biggy though. Just need to add a conditional variable to reset the clock if added time takes it past 23.
That one is actually a feature since you cannot "add" something to your clock. You can only "set" a new time. However I can see how it might be useful to have the check inside the method itself. I am going to add an internal check in the next version of the script.
I could probably just do this too:

$game_clock.set_time($game_clock.phase + time % 48)

I feel silly for not thinking of it earlier. ^///^;
Yes, the modulo operator solves a lot of problems. However, an internal check is still something that I am going to add in the next update. It is just a matter of using the modulo operator inside the method itself, no big deal at all.
Random question: I'm trying to display the time in the save file, so that it appears (among other data) when the player selects said file. I do this by calling $game_clock.to_s, but in this instance it shows up as 12:00 AM. I'm guessing that's because I'm on the title screen and not in the file itself, so the value probably defaults to "0". Is there a way I could reference the most recent time state the user left off on?
Sorry for double posting, but I think I found a minor bug. When checking the current hour, there seems to be an issue with "close calls". The context for this is a schedule system I have for NPCs. In this example:

Code:
Conditional Branch: $game_clock.hour24 > 8 && $game_clock.hour24 < 21
   /*Day Schedule*/
Else
   /*Night Schedule*/
Branch End

For the most part, this will work fine. If you enter the area and it's 9:00 AM or so, the NPC should be doing his Day Schedule. If you come in at 9:00 PM, he will be doing his Night Schedule. But sometimes if you go into his house right after 9:00 AM or PM, I will get the wrong result. In my case, I can rush in right as 9:00 AM starts and he'll be finishing his Night Schedule instead of starting his Day Schedule.

This can lead to weird behavior like going inside his house right as he exits it and, when you're inside, see him inside and heading towards the front door to leave. The window in which this happens is pretty small, so this isn't a major issue, but I thought I'd point it out.
Is there a way I could reference the most recent time state the user left off on?
Unfortunately not without a script that changes what is displayed in the Scene_Load window. Your guess is correct: the variable $game_clock is initialized when the game is loaded, as such you cannot display its value outside the game without getting that information directly from the save file.

Concerning your second post (it does not count as double post if more than 72 hours have passed so there is nothing to be sorry about) the method itself just returns the result of an integer division, having a bug there would be very unlikely. I think the error might lie within the event itself (or other events controlling it). Just to be sure, try putting this before that conditional branch:
Code:
puts "Current time 24: #{$game_clock.hour24}"
puts $game_clock.to_s
puts "---------------"
30.times  { Fiber.yield }
The first part prints the current time in your console, the second part stops the event for half a second, giving you enough time to check the result.
OK I figured out what was wrong--it was on my implementation, sorry. ^^; The problem is that when I had the schedules reset, they would run again while the player was moving to the next area. So when the player left the room, if the Schedule was set to Day Schedule, it would return to Neutral Schedule...and Neutral Schedule would run, realize it's day, and set it back to day schedule as the player was leaving, which meant there wasn't a proper reset. To fix this, I simply had to edit the schedules so the NPC would be set at the appropriate place, but the schedule wouldn't set itself to day or night until a second later, giving the player enough time to exit if need be.
OK I figured out what was wrong--it was on my implementation, sorry.
Do not worry, I was quite sure it was a "pilot" problem. As I mentioned, it was almost impossible to have a bug with that method. On top of it, if there was a bug, problems would start appearing everywhere else as well.
@KingHazeel I updated the script. The set_time method has now an internal check. I also fixed bug with the force_update method. Both the update log and the script link have been updated accordingly.
Updated version, now with new Terms of Use. The Terms of Use for this new version do not restrict the usage of this script. The only difference with the previous Terms of Use lies in how you have to credit me (a link to my website is required now). You can review the full license following the link in the first post.
Wouldn't it be nice to have a function to branch how many days have already passed ingame? 🙂 A small interface showing "Day: 1", "Day: 2" and so on would also be pretty useful I think.

Greetings,
Tw0Face

Original thread: https://forums.rpgmakerweb.com/threads/customizable-clock-and-time-day-night-cycle.97562/