integer SoundFileNum = 0; float TimerInterval = 10.0; PlayNextSound(string prefix) { string SoundFile; ++SoundFileNum; SoundFile = prefix + llGetSubString("00" + (string)SoundFileNum, -2, -1); if (llGetInventoryType(SoundFile) != INVENTORY_SOUND) { SoundFileNum = 1; SoundFile = prefix + llGetSubString("00" + (string)SoundFileNum, -2, -1); } llOwnerSay("Playing " + SoundFile); llLoopSound(SoundFile, 1.0); } default { state_entry() { vector sun = llGetSunDirection(); if (sun.z < 0) state night; SoundFileNum = 0; PlayNextSound("D"); llSetTimerEvent(TimerInterval); } timer() { vector sun = llGetSunDirection(); if (sun.z < 0) state night; PlayNextSound("D"); } changed(integer change) { if (change & (CHANGED_REGION_START | CHANGED_REGION)) { llResetScript(); } } } state night { state_entry() { SoundFileNum = 0; PlayNextSound("N"); llSetTimerEvent(TimerInterval); } timer() { vector sun = llGetSunDirection(); if (sun.z > 0) state default; PlayNextSound("N"); } changed(integer change) { if (change & (CHANGED_REGION_START | CHANGED_REGION)) { state default; } } }