Lights that are actually off

What It Does
The following two scripts will completely turn off candelabras that are supposed to be off. It should be possible to adapt these scripts to other placeable light sources. Place the first script in the OnEnter event of an area, and put the second in its OnExit. Two notes: 1) These scripts do not check if the objects are in the same area that is running the script, so it could effect the whole module. The easiest thing to do is give the light sources in the area a tag that is unique to that area. Or you could add code to check that the area of the object is the same as the area calling the script. 2) The second is just an optimization issue. I know that the SetLocalInt calls in the while loops of the two scripts are not necessary in a single player game. They may not be necessary in a multi-player game either, but test before you remove them.

Script 1
void main { if( GetIsPC(GetEnteringObject) ) {   // Initialize variables int nNth = 0; // Get first light object oLight = GetObjectByTag( "Candelabra", nNth ); // While oLight is a valid object while( GetIsObjectValid( oLight ) ) {       // If it's off, make sure it's off if( !GetLocalInt( oLight, "NW_L_AMION" ) ) {           // Turn off any visible flames or other animations. AssignCommand( oLight, PlayAnimation( ANIMATION_PLACEABLE_DEACTIVATE ) ); // Turn off the illumination effect. SetPlaceableIllumination( oLight, FALSE ); // Be sure to set the local int to 0 to show it's off. SetLocalInt( oLight, "NW_L_AMION", 0 ); }       // Increment the counter. nNth++; // Get the next light. oLight = GetObjectByTag( "Candelabra", nNth ); }   // After looping through all requested light objects, recompute the // lighting for the area so it is appropriately dark. RecomputeStaticLighting( OBJECT_SELF ); } }

Script 2
void main { // If a PC is leaving, relight all of the candelabras, // so they can be turned back off when a PC re-enters if( GetIsPC( GetExitingObject ) ) {    int nNth = 0; int nLightOff = 0; // Get first light object oLight = GetObjectByTag( "Candelabra", nNth ); // While oLight is a valid object while( GetIsObjectValid( oLight ) ) {        // If it's off, we have to relight it so         // we can shut it off at the next entrance if ( !GetLocalInt( oLight, "NW_L_AMION" ) ) {            // Turn on any visible flames or other animations. AssignCommand(oLight, PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE)); // Turn on the illumination effect. SetPlaceableIllumination(oLight, TRUE); // Be sure to set the local int to 0 to show it's off. SetLocalInt(oLight,"NW_L_AMION",0); }        // Increment the counter. nNth++; // Get the next light. oLight = GetObjectByTag("Candelabra", nNth); } } }