Jump to content

Yet Another Automated Light without llSensor, using llGetAgentList


MartinRJ Fayray
 Share

You are about to reply to a thread that has been inactive for 4113 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

float fTimer = 2.0; //interval to check for nearby agents
float fDistance = 10.0; //range to scan
vector vLight = <1.0, 1.0, 1.0>; //prim_point_light's color
float fIntensity = 1.0; //prim_point_light's intensity
float fRadius = 10.0; //prim_point_light's radius
float fFalloff = 0.5; //prim_point_light's falloff
integer i_bool_On = FALSE; //stores the light's status
default
{
    state_entry()
    { //start a timer on startup of the script
        llSetTimerEvent(fTimer);
    }

    timer()
    {
        list lAvatars = llGetAgentList(AGENT_LIST_PARCEL, []); //retrieve agent list in the parcel
        integer iCount; //helper variable
        integer i_bool_Found = FALSE; //becomes TRUE when an agent was detected within "fDistance"-range
        for (iCount = 0; iCount < llGetListLength(lAvatars); iCount++)
        { //loop through all agents...
            if (llVecDist(llList2Vector(llGetObjectDetails(llList2Key(lAvatars, iCount), [OBJECT_POS]),0), llGetPos()) <= fDistance)
            { //...and calculate distance from this prim
                i_bool_Found = TRUE; //avatar found...
                iCount = llGetListLength(lAvatars); //...break out of the loop
            }
        }
        if (i_bool_Found)
        { //must be on
            if (!i_bool_On)
            { //turn on
                i_bool_On = TRUE; //remember status = TRUE (on)
                llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, vLight, fIntensity, fRadius, fFalloff]);
            }
        }
        else
        { //must be off
            if (i_bool_On)
            { //turn off
                i_bool_On = FALSE; //remember status = FALSE (off)
                llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, vLight, fIntensity, fRadius, fFalloff]);
            }
        }
    }
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4113 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...