RecomputeStaticLighting(object)

From NWN Lexicon
Jump to navigationJump to search

Recomputes the lighting in an area based on current static lighting conditions.

void RecomputeStaticLighting(
    object oArea
);

Parameters

oArea
The area that needs its static lighting conditions recomputed.


Description

All clients in oArea will recompute the static lighting.

This can be used to update the lighting after changing any tile lights or if placeables with lights have been added/deleted via. SetPlaceableIllumination.


Remarks

For placeable objects that are sources of illumination (such as the lamp post), it is not enough to just use PlayAnimation with ANIMATION_PLACEABLE_DEACTIVATE or ANIMATION_PLACEABLE_ACTIVATE. That just affects the glowing part of the animation, itself. You must also use the SetPlaceableIllumination command set to TRUE and tell the area it's in to RecomputeStaticLighting.


Known Bugs

There is a known issue with respect to placeables using lights defined in placeables.2da and controlled with SetPlaceableIllumination - the game will always default the light to on irrespective of the animation state. Since this information is sent when the area is first entered, the SetPlaceableIllumination must be called before any PCs enter an area if you want the lights to be off. An example script to help with this is on the SetPlaceableIllumination page.


Example

// From David Gaider's Scripting FAQ
// will turn the lightable object on and off when selected
// placed in its OnUsed event
void main()
{
   if (GetLocalInt (OBJECT_SELF,"NW_L_AMION") == 0)
   {
      SetLocalInt (OBJECT_SELF,"NW_L_AMION",1);
      PlayAnimation (ANIMATION_PLACEABLE_ACTIVATE);
      SetPlaceableIllumination (OBJECT_SELF, TRUE);
      RecomputeStaticLighting(GetArea(OBJECT_SELF));
   }
   else
   {
      SetLocalInt (OBJECT_SELF,"NW_L_AMION",0);
      PlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);
      SetPlaceableIllumination (OBJECT_SELF, FALSE);
      RecomputeStaticLighting(GetArea(OBJECT_SELF));
   }
}

See Also

functions: 

SetPlaceableIllumination SetTileMainLightColor SetTileSourceLightColor



 author: Tom Cassiotis, editor: Lilac Soul