thats awsome, i found a workaround for that a bit ago, but i think ill remake it your way instead :)
as for detecting midnight i actually just figured that out myself by modifying code from lugnut's daycycle events, it dosent find midnight, but it will find 6am, which works for me
heres what i came up with:
function getDayCycleTime() //Returns the time in seconds from dawn from the current time
{
%curTime = $Sim::Time; // the day cycle is tied directly to the simTime of the server.
%length = $WeatherMod_Daylength; // this is how long in seconds the day will last. for example, 24 is a full 24 hour day in the space of 24 seconds.
%offset = DayCycle.dayOffset; // this is how much offset is applied to the day.
%offset = mfloor(%offset * %length); // this calculates how many seconds the offset actually affects, as the offset is defined in a range between 0 and 1.
if(%offset != 0)
%curTime = (%curTime + %offset) - %length; // this adds the offset into the equation.
%final = mFloor(%curTime % %length); // this determines the remainder of simTime divided by length, which is how far, in seconds, we are into the day.
if(%final < 0) //if the result is a negative, we need to subtract it from the total. this allows compatibility with offsets.
%final = %length - %final;
return %final;
}
function GetMidNight() // Find Midnight and schedule the Weathermod Time scripts.
{
%tod = getDayCycleTime(); // establish a starting point
%len = $WeatherMod_Daylength; // establish length of days
%seconds = %len - %tod;
%Miliseconds = %seconds * 1000;
$Sched_WeatherMod_Time = schedule(%Miliseconds,0,Time_6AM);
echo(%Miliseconds);
}