Recent changes Random page
GAMING
Gaming
 
WoWWiki
Halopedia
FFXIclopedia
Age of Conan
Warhammer Online
Grand Theft Wiki
See more...

Day and night lamp posts

From NWNWiki

Jump to: navigation, search

This script turns lamp posts in an area on at nights, and off during the day.

[edit] The Script

Place the script on a sigle lamp post. Make sure to uncheck "static" then place the script on the lamp posts onheartbeat.

void main()
{
    // define data storage object
    object obj = OBJECT_SELF;
    int iLampsOn = GetLocalInt(obj, "iLampsOn");
    int iChange = FALSE;
    if(!iLampsOn && (GetIsDusk() || GetIsNight() || GetIsDawn()))
        iChange = TRUE;
    else if(iLampsOn && GetIsDay())
        iChange = TRUE;
    if(iChange)
    {
        int i = 0;
        object oLamp = GetObjectByTag("LampPost");
        while(GetIsObjectValid(oLamp))
        {
            if(iLampsOn) // if lamps are currently on, turn this <span class="highlight">lamp</span> off
            {
                AssignCommand(oLamp, PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
                SetPlaceableIllumination(oLamp, FALSE);
            }
            else
            {
                AssignCommand(oLamp, PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
                SetPlaceableIllumination(oLamp, TRUE);
            }
            i++;
            oLamp = GetObjectByTag("LampPost", i);
        }
        RecomputeStaticLighting(GetArea(GetObjectByTag("LampPost")));
        iLampsOn = iLampsOn ? 0 : 1;
        SetLocalInt(obj, "iLampsOn", iLampsOn);
    }
}
Rate this article:
Share this article: