quote:
Originally posted by Gareth_2007
say it was 9 am merlin would say merlin.Speak("Good Morning");
and he would say that untill 12pm when he would say merlin.Speak("Good afternoon"); any ideas how that could be scripted? cheers
I put this code in my Merlin script.
 
code:
// function to have system hour. 
================================  
function TimeD(){ 
    var d, H, s = ""; 
    var c = ":"; 
    //var e = " Minutes "; var f = " Seconds "; var g = " Miliseconds!" 
    d = new Date();
    H = d.getHours()
    s += d.getHours() + c;
    Debug.Trace("S ="+s);      
    if (H == 13){s  ="1:"}; 
    if (H == 14){s  ="2:"}; 
    if (H == 15){s  ="3:"};
    if (H == 16){s  ="4:"}; 
    if (H == 17){s  ="5:"}; 
    if (H == 18){s  ="6:"}; 
    if (H == 19){s  ="7:"};
    if (H == 19){s  ="8:"};
    if (H == 19){s  ="9:"};
    if (H == 19){s  ="10:"};
    if (H == 19){s  ="11:"};
    s += d.getMinutes();
    if (H <  12){s +=" am "};    
    if (H >  12){s +=" pm "};     
    Debug.trace("TIME = "+s); 
    //s += (" and ")+d.getSeconds() + f;    //if you want more precision 
    //s += d.getMilliseconds() + g;         //if you want more precision 
    return(s); 
}
    // exemple : Merlin.Speak(TimeD())
    // Whit the condotional code you can.
code:
// To have the current date of the style of the medieval age.  
=============================================================
function DateD(){ 
var d, day, mont, date, year, x, y, s = "\\spd=180\\We are ";     
var x = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
var y = new Array("January","February","March ","April","May","June","July","August","September","October","November","December"); 
d = new Date(); day = d.getDay(); month = d.getMonth(); date = d.getDate(); year = d.getFullYear();
if (date == 1){
date += "st"
}else if (date == 2){
date += "nd"
}else if (date == 3){
 date += "rd"
}else if (date > 3 ){
date += "th"
}else if (date == 21){
date += "st"
}else if (date == 22){
date += "nd"
}else if (date == 23){
date += "rd"
}else if (date > 23){
date += "th"
}else if (date == 31){
date += "st"
        }
return(s +=("Today is ")+x[day]+(", ")+y[month]+(" ")+date+(" in the years of grace ")+year); 
}
 
It work perfectly add the command Merlin.Speak(GetTimeOfDay) in
the function : OnEvent_SigninReady(Email)
To grab period of day. 

===========================
code:
function GetTimeOfDay(){
    var dd, hh, TimeOfDay = ""
    dd = new Date();
    hh = dd.getHours();
        
    if (dd < 5){  
        TimeOfDay = "\\Spd=180\\Good Night!"
} else if (hh < 9){
        TimeOfDay = "\\Spd=180\\Good Morning!"
} else if (hh < 12){
        TimeOfDay = "\\Spd=180\\Good Morning!"                
} else if (hh == 12){
        TimeOfDay = "\\Spd=180\\Good noon!"        
} else if (hh < 17){ 
        TimeOfDay = "\\Spd=180\\Good after noon!"        
} else if (hh == 17){
        TimeOfDay = "\\Spd=180\\Good Supper!"
} else if (hh < 21){  
        TimeOfDay = "\\Spd=180\\Good Evening !"            
} else if (hh >= 21){ 
        TimeOfDay = "\\spd=180\\Good Night!"  
    }
    return (TimeOfDay);
}