NWScript:
void _BM062_AutoLightsStateReset(){
object oFirstLight = GetObjectByTag("_AutoLight_00");
SetLocalInt(oFirstLight, "NightSet", 0);
SetLocalInt(oFirstLight, "DaySet", 0);
}
void _BM062_AutoLights(){
int x;
object oPlaceableLight;
object oFirstLight = GetObjectByTag("_AutoLight_00");
object oCurrentArea = GetArea(oFirstLight);
if ((GetIsNight() == TRUE || GetIsDusk() == TRUE) && GetLocalInt(oFirstLight, "NightSet") == 0){
SetLocalInt(oFirstLight, "NightSet", 1);
SetLocalInt(oFirstLight, "DaySet", 0);
for (x=0;x < 100;x++){
if (x < 10) oPlaceableLight = GetObjectByTag("_AutoLight_0" + IntToString(x));
else oPlaceableLight = GetObjectByTag("_AutoLight_" + IntToString(x));
if (GetIsObjectValid(oPlaceableLight) != TRUE) break;
AssignCommand(oPlaceableLight, PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
SetPlaceableIllumination(oPlaceableLight, TRUE);
SetLocalInt(oPlaceableLight, "NW_L_AMION", 1);
}
RecomputeStaticLighting(oCurrentArea);
}
if ((GetIsDay() == TRUE || GetIsDawn() == TRUE) && GetLocalInt(oFirstLight, "DaySet") == 0){
SetLocalInt(oFirstLight, "NightSet", 0);
SetLocalInt(oFirstLight, "DaySet", 1);
for (x=0;x < 100;x++){
if (x < 10) oPlaceableLight = GetObjectByTag("_AutoLight_0" + IntToString(x));
else oPlaceableLight = GetObjectByTag("_AutoLight_" + IntToString(x));
if (GetIsObjectValid (oPlaceableLight) != TRUE) break;
SetPlaceableIllumination(oPlaceableLight, FALSE);
AssignCommand(oPlaceableLight, PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
SetLocalInt(oPlaceableLight, "NW_L_AMION", 0);
}
RecomputeStaticLighting(oCurrentArea);
}
}