SetPlaceableIllumination(object, int)
Sets the illumination for a placeable on or off.
void SetPlaceableIllumination(
object oPlaceable = OBJECT_SELF,
int bIlluminate = TRUE
);
Parameters
- oPlaceable
- The placeable whose illumination will be changed. (Default: OBJECT_SELF)
- bIlluminate
- If this is TRUE, oPlaceable's illumination will be turned on. If this is FALSE, oPlaceable's illumination will be turned off. (Default: TRUE)
Description
Set the status of the illumination for oPlaceable.
It will only affect placeables with a LightColor setting in placeables.2da.
Remarks
You must call RecomputeStaticLighting after calling this function in order for the changes to occur visually for the players. SetPlaceableIllumination() buffers the illumination changes, which are then sent out to the players once RecomputeStaticLighting() is called. As such, it is best to call SetPlaceableIllumination() for all the placeables you wish to set the illumination on, and then call RecomputeStaticLighting() once after all the placeable illumination has been set.
Note for advanced users, the state of this is saved to save games using the GFF parameter "LightState", which could be used to prime the state (which defaults to on if not set as per Known Bugs below).
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 below.
Example
// Can be run OnModuleLoad
void main()
{
// Turn off all lighting attached to all placeables. You could
// use local variables on objects to control it, but sadly
// you cannot get the current animation state of a placeable.
object oArea = GetFirstArea();
while (GetIsObjectValid(oArea))
{
object oObject = GetFirstObjectInArea(oArea);
while (GetIsObjectValid(oObject))
{
if (GetObjectType(oObject) == OBJECT_TYPE_PLACEABLE)
SetPlaceableIllumination(oObject, FALSE);
oObject = GetNextObjectInArea(oArea);
}
oArea = GetNextArea();
}
}
See Also
| functions: |
author: Tom Cassiotis, editor: Lilac Soul