generated from Jaysyn/ModuleTemplate
Initial Commit
Initial Commit.
This commit is contained in:
69
_module/nss/lightonoff.nss
Normal file
69
_module/nss/lightonoff.nss
Normal file
@@ -0,0 +1,69 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Automatically turn lights on during the night or off during the day
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Modified By: Stephen M. LaBar, Jr.
|
||||
// Modified On: 08/07/2002
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Currently this goes into the OnHeartbeat event handler for an invisible
|
||||
// object located in a high traffic area. For ease of use I named my invisible
|
||||
// object LightOnOff.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Make a custom placeable light with the tag LampPost and place it in whatever
|
||||
// area you want in your module.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
object oLamp;
|
||||
int nNth=0;
|
||||
oLamp = GetObjectByTag("LampPost", nNth);
|
||||
|
||||
int validDay = GetIsDawn() || GetIsDay();
|
||||
int validNight = GetIsDusk() || GetIsNight();
|
||||
|
||||
|
||||
// This part of the script only runs one time.
|
||||
if (GetLocalInt (OBJECT_SELF,"RUNONCE") != 1)
|
||||
{
|
||||
while (GetIsObjectValid(oLamp))
|
||||
{
|
||||
SetLocalInt(OBJECT_SELF,"RUNONCE",1);
|
||||
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
|
||||
SetPlaceableIllumination(oLamp, FALSE);
|
||||
SetLocalInt(OBJECT_SELF,"NW_L_AMION",0);
|
||||
RecomputeStaticLighting(GetArea(oLamp));
|
||||
nNth++;
|
||||
oLamp = GetObjectByTag("LampPost", nNth);
|
||||
};
|
||||
}
|
||||
|
||||
// This part of the script only runs once at validNight.
|
||||
if (validNight && GetLocalInt(OBJECT_SELF, "NW_L_AMION") == 0 )
|
||||
{
|
||||
while (GetIsObjectValid(oLamp))
|
||||
{
|
||||
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
|
||||
SetPlaceableIllumination(oLamp, TRUE);
|
||||
SetLocalInt(OBJECT_SELF,"NW_L_AMION",1);
|
||||
RecomputeStaticLighting(GetArea(oLamp));
|
||||
nNth++;
|
||||
oLamp = GetObjectByTag("LampPost", nNth);
|
||||
};
|
||||
}
|
||||
|
||||
// This part of the script only runs once at validDay.
|
||||
if (validDay && GetLocalInt(OBJECT_SELF, "NW_L_AMION") == 1)
|
||||
{
|
||||
while (GetIsObjectValid(oLamp))
|
||||
{
|
||||
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
|
||||
SetPlaceableIllumination(oLamp, FALSE);
|
||||
SetLocalInt(OBJECT_SELF,"NW_L_AMION",0);
|
||||
RecomputeStaticLighting(GetArea(oLamp));
|
||||
nNth++;
|
||||
oLamp = GetObjectByTag("LampPost", nNth);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user