- Home /
 
How Would I Change This To Read Within A Time Range?
I have this system time reference script that I would like to change so that instead of doing something on hour it did it within a time range say between 8:00 to 12:00 noon. How would I change the setting of this script so that it does that?
 void Awake () {
         if (sending == null) {
             DontDestroyOnLoad (gameObject);
             sending = this;
         } else if (sending != this) {
             Destroy (gameObject);
         }
         MessageCentreText.text = "CALIBRATE";
 
     //Time OF Day Notification
     //Noon Time
     if (sysHour == 12) {
         GetComponent<AudioSource>().clip = timeVoicesNoon[Random.Range(0,timeVoicesNoon.Length)];
         GetComponent<AudioSource>().Play();
             MessageCentreText.text = "GOOD AFTERNOON";
             Debug.Log ("Good Afternoon!");
     } 
     //Morning Time
     else if (sysHour == 8) {
         GetComponent<AudioSource>().clip = timeVoicesMorning[Random.Range(0,timeVoicesMorning.Length)];
         GetComponent<AudioSource>().Play();
             MessageCentreText.text = "GOOD MORNING";
             Debug.Log ("Good Morning!");
     }
     //Night Time
     else if (sysHour == 22) { 
         GetComponent<AudioSource>().clip = timeVoicesNight[Random.Range(0,timeVoicesNight.Length)];
         GetComponent<AudioSource>().Play();
             MessageCentreText.text = "GOOD EVENING";
             Debug.Log ("Good Night!");
     }
 
         else{
         //Do something if desired
             MessageCentreText.text = "KNIGHT INDUSTRIES 2000";
         Debug.Log("Go to bed!");
     }
 }
 
              Sooooo is there a way to do this between a set time range like: 8:00 to 12:00 A$$anonymous$$?
 if (sysHour == 13) {
             $$anonymous$$essageCentreText.text = "GOOD AFTERNOON";
             Debug.Log ("Good Afternoon!");
                 Answer by KnightRiderGuy · Dec 08, 2015 at 03:56 PM
I had forgotten that if I change it to this it works within a certain range.
 if (sysHour > 13) {
 
               It's not precisely between something like 8 Am and 11 Am but it works.
Your answer
 
             Follow this Question
Related Questions
Timer reset 1 Answer
Javascript beginner here: how do I implement time such as hours and days? 2 Answers
Clock Script From Java to C# Help 1 Answer
How can I have timespan display less 2 Answers
Smaller Time Interval? 3 Answers