FANDOM


Dm kill
This page is a candidate for deletion.

If you disagree with its deletion, please explain why on its talk page. If this page obviously does not meet the criteria for deletion, or you intend to fix it, please remove this notice, but do not remove this notice from articles that you have created yourself.

Administrators: Remember to check if anything links here and the page history before deleting.

These lights that are actually off 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 event. 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 Edit

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 Edit

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);
     }
  }
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.