switching lights, or a number of them
Posted: Wed Oct 08, 2003 11:54 am
comments welcome.
Especially regarding perfomance, possibilities where this can go
hideously wrong, etc.
If no one can find something serious, I would propose this to be included in player housing, as many probably would like to switch lights on or off...
Especially regarding perfomance, possibilities where this can go
hideously wrong, etc.
If no one can find something serious, I would propose this to be included in player housing, as many probably would like to switch lights on or off...

Code: Select all
/*
ply_lightswitch is a set of two scripts that help
switching a number of lights on or off.
It consists of two functions: ply_SwSingleLight and
ply_Sw_MassLight.
ply_Sw_SingleLight just takes the existance of the
given object for granted, and turns it on or off,
depending on intOnOff. It also recomputed lighting.
ply_Sw_MassLight cycles through a bunch of objects,
by building the object tags out of a root tag and a
running number. It then invokes ply_Sw_SingleLight
to handle the actual turning on or off.
//::///////////////////////////////////////////////
//:: ply_SwSingleLight
//::
//:://////////////////////////////////////////////
/*
This switches one object (oSwObject) on or off,
depending on intOnOff (on=TRUE, off=FALSE, Default=FALSE)
*/
void ply_SwSingleLight(object oSwObject, int intOnOff = FALSE)
{
// actual switching on or off of a single object.
if (intOnOff == TRUE)
{
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
DelayCommand(0.4,SetPlaceableIllumination(oSwObject, TRUE));
SetLocalInt(oSwObject,"NW_L_AMION",1);
DelayCommand(0.5,RecomputeStaticLighting(GetArea(oSwObject)));
}
else
{
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
DelayCommand(0.4,SetPlaceableIllumination(oSwObject, FALSE));
SetLocalInt(oSwObject,"NW_L_AMION",0);
DelayCommand(0.9,RecomputeStaticLighting(GetArea(oSwObject)));
}
}
//::///////////////////////////////////////////////
//:: ply_SwMassLight
//::
//:://////////////////////////////////////////////
/*
This cycles through a number of objects stored in
intObjCount, starting at 0. If the object exists,
it switches it on or off, according to intOnOff.
*/
void ply_SwMassLight(string strObjTagStart, int intObjCount, int intOnOff = FALSE)
{
string strObjTag;
int i=0;
object oToSwitch;
while(i<=intObjCount){
oToSwitch = GetObjectByTag(strObjTagStart + IntToString(i));
if (oToSwitch != OBJECT_INVALID) ply_SwSingleLight(oToSwitch,intOnOff);
i++;
}
}