Author Sticky: Post Working Scripts Here
Tenchi Masaki Posted: Monday, 22 July 05:12AM
1. Script Name: Torches don't light themselves
Script Creator: Frank V. Schumacher

2. What it does: Has an NPC monitor the time of day and lights or puts out torches accordingly.

3. Notes: Well, I'm new at this so there should be a note that this might contain a lot of shortcomings that I don't understand.
The placeable Item in this script (the one that will be interacted with and should be a light source) should have the NWN script "nw_02_onoff" in its OnUsed script.

This script goes in the heartbeat script of an NPC. Change the tag on your object accordingly.

NWScript:
void main()

{

    object oLightSource = GetObjectByTag("StandingTorch_001");

    {

        if(GetIsDawn() == TRUE && GetPlaceableIllumination(oLightSource) == TRUE

        || GetIsDay() == TRUE && GetPlaceableIllumination(oLightSource) == TRUE)

                    {

                        if(IsInConversation(OBJECT_SELF) == FALSE

                        || GetIsInCombat(OBJECT_SELF) == FALSE)

                            {

                                ClearAllActions();

                                ActionInteractObject(oLightSource);

                                DelayCommand(4.5, ActionRandomWalk());

                            }

                    }

        else if(GetIsDusk() == TRUE && GetPlaceableIllumination(oLightSource) == FALSE

        || GetIsNight() == TRUE && GetPlaceableIllumination(oLightSource) == FALSE)

                    {

                        if(IsInConversation(OBJECT_SELF) == FALSE

                        || GetIsInCombat(OBJECT_SELF) == FALSE)

                            {

                                ClearAllActions();

                                ActionInteractObject(oLightSource);

                                DelayCommand(4.5, ActionRandomWalk());

                            }

                    }

    }

}


Well, It works for me except that the standing torches default to a glowing beacon of light. I'm working on that. Please tell me if something is wrong with this.