Jump to content

Sensor / SensorRepeat on List of Avatar Names


Joris Hudson
 Share

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

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

Recommended Posts

Im working on a sensor script that must perform an action when a specified avatar is nearby. Now the problem im stuck with is the following line:

 

llSensorRepeat("Avatar Name", NULL_KEY, AGENT, 5, PI, 5);

 

To make it react on one "avatar name" you simply add the name to the line. But I want to add more names to it so it reacts on several "Avatar Names".. Im trying out a list command to get avatars added.. Or working with notecards thats been reading into the script to check on names But none of this seems to work.

 

So the question is, does anyone know how to make a Sensorrepeat script that reacts on specified "Avatar Names"

 

 

Link to comment
Share on other sites

list lNAMES = ["freya.mokusei"]; //Expandable list.default{    state_entry()    {        llSensorRepeat("","",AGENT,96.0,5); //set up sensorrepeat    }    sensor(integer num_det)    {        integer i;        for(i = 0; i < num_det; i++) //for loops through each avatar within range.        {            if(llListFindList(lNAMES,[llGetUsername(llDetectedKey(i))]) != -1) //Test for each username being in list.            {

                //true; llOwnerSay("Name in list found by sensor: " + llGetUserName(llDetectedKey(i))); } } }}

 This is probably not the most memory-efficient way to do it, but it is the easiest to read.

Note however that Sensors only return a maximum of 16 results. If you're using this on a busy region, or requiring a test against every avatar (e.g. for a security device), you would be better using llGetAgentList.

  • Like 1
Link to comment
Share on other sites

Thank you for the fast reply. However the script doesnt seem to work. sniff

 

 

Well its basically ment for me and some friends.. that we are around .. some things are auto-rezzed .. and when we leave.. that they are auto-deleted again. So I think I can work with this script to see if it works. But if you have a better idea to make it less lag than please let me know.

Link to comment
Share on other sites

I can't get in-world to test it will compile. If you know the specific fault and line number I can likely correct it.

It does occur to me that it might be better with:

for(i = 0; i <= num_det; i++)

And remember of course it is looking for username in pattern 'firstname.lastname', including period and all lower case.

But I have no idea without testing or fault codes. Logically it all works, suggest you check the LSL wiki to familiarise with the functions? Improvement and lag-reduction could be done by for-looping at the end of sensor; but this would require some matrix-style comparison which may/may not be relevant. I only provide example, not finished script.

Link to comment
Share on other sites

Senors are are laggy and as Freya pointed out, they will only list the 16 closest agents detected.  It's smarter to use llGetAgentList and a timer.  Here's one approach (not field tested, just off the top of my head):

list gMyFriends = [ "put your friends' UUIDs in a list here"];integer gStillHere;default{	state_entry()	{		llSetTimerEvent(30.0);	}	timer()	{		list Avs = llGetAgentList(AGENT_LIST_REGION,[]);		integer i = llGetListLength(gMyFriends);		integer Here = FALSE;		while (i >= 0)		{			if (~llListFindList(Avs,[llList2Key(gMyFriends,i)]))			{				Here = TRUE;			}			--i;		}		if (Here && (!gStillHere))	//Don't rez one if therre's already one there. Otherwise, go ahead		{			llRezAtRoot("Stuff",llGetPos() + <1.0,1.0,0.0>,ZERO_VECTOR,ZERO_ROTATION,0);			gStillHere = TRUE;		}		else if (!Here)	//Delete "Stuff"		{			llRegionSay(-12345,"DIE");			gStillHere = FALSE;		}	}}

 You'd need to put a suicide script into your "Stuff" so that it will hear the DIE message, of course.

ETA: It's probably worth asking why you bother wiping out stuff when you guys leave.  After all, you create sim lag whenever you rez things. Unless you just don't want other people looking at your things after you leave, why go to all this trouble?

  • Like 1
Link to comment
Share on other sites

Thank you for your help. Also this script doesnt seem to work at first sight. But Ill keep trying to see if i can do something about it. The reason im looking for a script like this is cause I want to be carefull with prim use. So when me or my friends arent around.. There is more left for others to use on a temp base.

Link to comment
Share on other sites

Im testing the scripts on myself.. So in the first script I type in my name ... and in the second script my UUID. I set the action to make it say something on local chat so that i can see that it performs the action when im within range. So far nothing happens when im close.

Link to comment
Share on other sites

Did you put the UUID in quotes?

Notice also that to save wear and tear on the sim's servers I have set the timer in my little script to fire every 30 seconds, so you won't see an instantaneous response.  It may take up to 30 seconds.

Link to comment
Share on other sites

list gMyFriends = [ "0000000-0000000-0000000-000000000"];integer gStillHere;default{	state_entry()	{		llSetTimerEvent(5.0);	}	timer()	{		list Avs = llGetAgentList(AGENT_LIST_REGION,[]);		integer i = llGetListLength(gMyFriends);		integer Here = FALSE;		while (i >= 0)		{			if (~llListFindList(Avs,[llList2Key(gMyFriends,i)]))			{				Here = TRUE;			}			--i;		}		if (Here && (!gStillHere))	//Don't rez one if therre's already one there. Otherwise, go ahead		{			llSay(0,"Avatar Identified");

llRezAtRoot("Stuff",llGetPos() + <1.0,1.0,0.0>,ZERO_VECTOR,ZERO_ROTATION,0);

gStillHere = TRUE;

}

else if (!Here) //Delete "Stuff"

{

llRegionSay(-12345,"DIE");

gStillHere = FALSE;

}

}

}

 

 

I placed my own UUID between the quotes " ".  And changed the repeater to 5 seconds. And added a Say command to make the object say something in local chat to see if the action works when im standing near. Unfortunetely no result yet.

Link to comment
Share on other sites

It works for me, but you must realize that llGetAgentList(AGENT_LIST_REGION,[]); gives you all agents in the region near and far away.
So standing near is no different from standing far
You must go to another region not to be detected

My working script is

list gMyFriends = [ "0000000-0000000-0000000-000000000"];integer gStillHere;default{    state_entry()    {        llSetTimerEvent(5.0);		gMyFriends = [llGetOwner()];    }    timer()    {        list Avs = llGetAgentList(AGENT_LIST_REGION,[]);        integer i = llGetListLength(gMyFriends);        integer Here = FALSE;        while (i >= 0)        {            if (~llListFindList(Avs,[llList2Key(gMyFriends,i)]))            {                Here = TRUE;            }            --i;        }        if (Here && (!gStillHere))    //Don't rez one if therre's already one there. Otherwise, go ahead        {            llSay(0,"Avatar Identified");             llRezAtRoot("Stuff",llGetPos() + <1.0,1.0,0.0>,ZERO_VECTOR,ZERO_ROTATION,0);             gStillHere = TRUE;         }         else if (!Here) //Delete "Stuff"         {             llRegionSay(-12345,"DIE");             gStillHere = FALSE;         }     }}

I was to lazy to type UUID so I used llGetOwner()

 

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites


Joris Hudson wrote:

I did tp out and back in.. the reason i need to stand close is so that i can hear the Say command in general chat if it works.. But i dont see it. And yes i placed in a box called "Stuff" to see if it would rezz.

Then you can use llRegionSayTo( llGetOwner(), 0, "Avatar Identified");

instead of llSay(0,"Avatar Identified");

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

This forum is not the place you get all finished and ready tailored scripts and I am not the only one saying that
It is a place where people help each other to workable solutions and no one get paid for their time
For ready made scripts you should enter your request in the commerce/wanted forum

I am sorry if you had a bad trip but I will not be responsible for that

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

Ah...mkay, gotcha :)

sorry, i use these forums to try and learn how to script,

and I can't thank you all enuff for all the help and advice you give :)

here is what i did with your scripts, this uses instant message to Owner

so i could test it by leaving my sim..this part can be deleted after you test it.

.this script clears the name lists every timer cycle, and

de Rez's only once when there are no "friends" around. it uses UUID's

from a notecard so you can add as many as you need.

 

list gMyFriends = [];integer gStillHere;string CurrNC;key nameQuery;list inRegion = [];list Avs;list AvsName;list  friendName = [];integer x;integer k;default{    state_entry()    {        CurrNC = llGetInventoryName(INVENTORY_NOTECARD, 0);        nameQuery = llGetNotecardLine(CurrNC, 0);         llSetTimerEvent(15.0);    }    touch_start(integer num)    {        k = !k;        if(k)        {            llOwnerSay("ON");            llSetTimerEvent(15.0);        }        else        {             llOwnerSay("OFF");             llSetTimerEvent(0);        }    }                 dataserver(key query_id, string data)     {        if (query_id == nameQuery)        {                          if (data == EOF)             {                     // llOwnerSay("endOFfile");            }            else             {                   gMyFriends +=  data;               ++x;               nameQuery = llGetNotecardLine(CurrNC, x);            }        }          }    timer()    {        AvsName = [];        friendName = [];        //______________________________________________                 Avs = llGetAgentList(AGENT_LIST_REGION,[]);         integer j = llGetListLength(Avs);         integer w;         for(w = 0;w < j;++w)         {             AvsName += llKey2Name(llList2Key(Avs, w));         }           string VisNames = llDumpList2String( AvsName, "\n ");           llInstantMessage( llGetOwner(), "\nVisitor names :\n" + VisNames );                      //__________________________________________                       integer i = llGetListLength(gMyFriends);            integer Here = FALSE;          while (i >= 0)         {            if (~llListFindList(Avs,[llList2Key(gMyFriends,i)]))            {                Here = TRUE;                friendName += llKey2Name(llList2Key(gMyFriends, i));                string Friends = llDumpList2String( friendName, "\n ");                llInstantMessage( llGetOwner(), "\nFriends in Region :\n" + Friends );            }                        --i;        }        if (Here && (!gStillHere))    //Don't rez one if therre's already one there. Otherwise, go ahead        {             llInstantMessage( llGetOwner(),"first time rez");                      //  llRezAtRoot("Stuff",llGetPos() + <1.0,1.0,0.0>,ZERO_VECTOR,ZERO_ROTATION,0);             gStillHere = TRUE;         }         else if (!Here && (gStillHere)) //Delete "Stuff"         {             llInstantMessage( llGetOwner(),"De rez");           //  llRegionSay(-12345,"DIE");             gStillHere = FALSE;         }          llSetTimerEvent(15.0);     }}

 

Link to comment
Share on other sites

As Dora pointed out, the idea in this forum is not to write free scripts for people, but to help them learn to write their own. That's why the script I posted didn't have all the bells and whistles -- and the failsafes -- that I would normally put in a finished script.  The basic script I presented illustrates an approach to the problem that the OP can build on. And it works.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4196 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...