Help with timing script

Hello I have a simple timing script and i can code farely well this is the first time i ran into a problem and it is bugging me. I need to know how in the following code i would edit it inorder to angle the light depending on the time of day rather than the light always facing down and simulating day when the game is run.

import System;
var date = DateTime.Now;
var timeDisplay : GUIText;

function Start() {
    InvokeRepeating("Increment", 1.0, 1.0);
}
function Update () {
    var seconds : float = date.TimeOfDay.Ticks / 10000000;
    transform.rotation = Quaternion.LookRotation(Vector3.up);
    transform.rotation *= Quaternion.AngleAxis(seconds/86400*360,Vector3.down);
    if (timeDisplay) timeDisplay.text = date.ToString("f");
}

function Increment() {
    date += TimeSpan(0,0,0, 1);
}

You could use condition statments to campare if the time is greater or less than a set condition then update the angle. So are you trying to get the day in your game to match the real time of day? :smile:

http://www.pixelstudio.nl/?p=138

Yes I am trying to have it match actual times of the day…In the game i have an option to choose how many minutes per second i have that part figured out

My problem is that my script takes the time from the users computer and i dont know how i would write the condition statment’s becasuse generally a condition statment is

If “variable” = “Value” then “Action” else “action”

But i do not know the variable name…i dont know how to explain this well but what i mean is what would the variable be i’ve tried things like 12:30 like time…And i’ve tried days but they dont work.

You could use the string to compare conditions

Just Examples

//Convert to string
var actualTime : String;
//Have the var read from the System
actualTime = System.DateTime.Now.ToString("hh:mm:ss");
//Compare
   if(actualTime=="12:00:00"){
   //Turn my light and wash my car-lol
}

I would update it every 15 minutes thats 96 times in a 24 hour period-lol But you will need a condition for AM and PM. for that i would compare the angle like if angle less than so and greater than so read the second 48 conditions. Ofc this is all theory :smile: