GetPlaceableIllumination(object)

From NWN Lexicon
Jump to navigationJump to search

Retrieves the current state of a placeables illumination.

int GetPlaceableIllumination(
    object oPlaceable = OBJECT_SELF
);

Parameters

oPlaceable
Placeable to check the illumination of (Default: OBJECT_SELF)


Description

Returns TRUE if oPlaceable's illumination is on and returns FALSE if otherwise.

It will only work with placeables with a LightColor setting in placeables.2da. Any placeable without this defined will always return FALSE.

Remarks

You can use this to test if a placeable is "actively lighting things up" and even use it for a slightly cleaner on/off script as per the example below.


Example

// Demonstrates how to turn on and off a placeable's illumination based on the time of day.
// Designed to be used in the OnHeartbeat event of the placeable object but to optimise 
// could be done in the area or modules heartbeat and done to all relevant placeables.

void main()
{
  if(GetTimeHour()==20)
  {
    // Sets the placeables illumination state to the opposite of what it already is
    SetPlaceableIllumination(OBJECT_SELF, !GetPlaceableIllumination());
    // Required for users to see static lighting changes
    RecomputeStaticLighting(GetArea(OBJECT_SELF));
  }
  else if(GetTimeHour()==6)
  {
    // Sets the placeables illumination state to the opposite of what it already is
    SetPlaceableIllumination(OBJECT_SELF, !GetPlaceableIllumination());
    // Required for users to see static lighting changes
    RecomputeStaticLighting(GetArea(OBJECT_SELF));
  }
}

See Also

functions: 

SetPlaceableIllumination



 author: Tom Cassiotis, editor: Sarev0k