Name: DS_GLOBAL_SDIAL
Function: Displays Time in hh:mm format, hh format at dawn/dusk and no time
at night. Thanks to Zinderin for minute/second workaround.
If anyone has functions to grab any environmental vars that will relay
weather, please forward them to the address in the code header.
Keywords for forum search: sundial, time, hours, minutes
NWScript:
void main()
{
if (GetIsNight()) {
SpeakString("It is night, therefore you cannot tell the time.",TALKVOLUME_TALK);
return;
} else {
int workHour = GetTimeHour();
int workMinute = GetTimeMinute();
workMinute = workMinute * 30;
int workSecond = GetTimeSecond();
if (workSecond >= 30) workMinute = workMinute + 15;
int workShowMinute;
string workShowTimeframe;
string workSMinute;
if (GetIsDawn()) {
workShowMinute = 0;
workShowTimeframe = "dawn";
} else {
if (GetIsDusk()) {
workShowMinute = 0;
workShowTimeframe = "dusk";
} else {
workShowMinute = 1;
workShowTimeframe = "daytime";
workSMinute = IntToString(workMinute);
if (GetStringLength(workSMinute) == 1) {
workSMinute = "0" + workSMinute;
}
}
}
string workDesignate = "AM";
if (workHour >= 13) {
workHour = workHour - 12;
workDesignate = "PM";
}
string workResult = "Because it is ";
workResult = workResult + workShowTimeframe;
workResult = workResult + ", you can work out that the time is ";
if (workShowMinute == 0) {
workResult = workResult + "roughly ";
}
workResult = workResult + IntToString(workHour);
if (workShowMinute == 1) {
workResult = workResult + ":" + workSMinute;
}
workResult = workResult + workDesignate;
SpeakString(workResult,TALKVOLUME_TALK);
}
}
|