I made a SetTime event for the Environmental Control event pack, but I cant get my head around the math. I'm fairly sure its simple math, but I've tried for hours now and I just cant work it out.
I have 4 variables; Offset, Time, SunTime and Amount. SunTime should be Time+Offset. I want to change Offset so that SunTime = Amount.
Time and Offset have to be between 0 and 1.
Relevant Code, in case i'm derping somewhere else, and its really obvious:
//Basically, since you cant even detect where the sun is, i use Lugnut's code below
//to work out the time its on, then calculate a fraction and move the offset by that.
%offset = $EnvGuiServer::dayOffset;
switch(%mode)
{
case 0: //set
%time = (getDayCycleTime()/$EnvGuiServer::dayLength);
%offset -= (%time+%Offset)-%amount;
case 1: //increase
%offset += %amount;
}
if(%offset > 1)
%offset -= 1;
if(%offset < 0)
%offset += 1;
serverCmdEnvGui_SetVar(FakeAdminClient,"DayOffset",%offset);
I've tried working it out, writing it down, I even made a flash app to help me, but nothing's working. If you can, go through it one step at a time, so I can see where i'm getting confused.