Jump to content

Detect avatar then select from, list


Juliena
 Share

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

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

Recommended Posts

I'm trying to create a script that will detect all avatars within a set range, using 60 at the moment, then to input the data collected into a list function so that you can detect, then select avatars in the nearby area. 

Examples of this type of script would be... well, any attack HUD in existance honestly. I've hit a pitfall in that you can't seem to use the list fuction and then set a sensor within it's scope.

Looking for any help on this situation, thanks. ^_^

Link to comment
Share on other sites

The old way to do it would be to use a sensor that is set to whatever range you wish, and then feed the results from that scan into your list.,  That approach is limited by the maxium range of an scanner (96m) and by the maximum number of things (people, etc.) that a sensor can detect in a single scan (16).  The better approach now is to use llGetAgentList, which has no distance limit within a region and has a much larger (100) limit on the number of avs it can detect.  It has the extra benefit for applications like yours that it output a list of UUIDs directly, so you don't need to compile one yourself.  Once you have the list, you can filter it in any way you like -- for specific avatars, for avatars within X meters of you, for avatars who are sitting, ......

I'm not sure what you mean by "I've hit a pitfall in that you can't seem to use the list fuction and then set a sensor within it's scope," or why you are trying to do that.  If you were using a sensor, you be creating the list with it, not the other way around. You query the list for information about a specific avatar, not to scan for him. 

Link to comment
Share on other sites

Thanks for the response on this, I aprpeciate the help. ^_^

Right, to answer your later confusion on the whole pitfall part, I was doing it that way because I was unsure how I'd do it another way. Essentially trying to imbed the sensors resultsas such

 

list scanner_results = [sensor( integer detected )];

 

Though it really didn't like that. I wasn't using llGetAgentList because, though I knew about it's advantages, I only wanted the shorter range. It's a close range aspect, though I was unaware that you could just filter for range/name/sitting etc. So in that regard I will be switching over, thanks for that advice on that!

However, I'm not actually sure how I'd filter the data to get range or certain people out with it. I'm aware how to do it with the list feature normally, inputting the distinguishing factors as absolutes, above the default start section and all that. Though I'm not sure how you'd do it after acquiring information during the script.

I attempted continuing with during the script using 

 

list nearby_avatars = llGetAgentList(AGENT_LIST_REGION, []);

 

Though I can't seem to then input that into a llDialog afterwards. Any thoughts? Thanks for any help that can be provided.

Link to comment
Share on other sites

I've already restricted it to just the parcel, though I'm after a limited range. The 96m was perfect, for example, though I'd probably restrict it to around 50m-70m depending on what I'm thinking. That's not the big issue though really. I can work without the restriction if necessary, it's more figuring out how I returned the sensor results (Now llGetAgentList(AGENT_LIST_REGION, []) ) and use those returned results to appear in a llDialog feature. 

Or if I even need to use it in the llDialog or whether I need to do something else. xD

Link to comment
Share on other sites

Ah, OK.  Once you have the list from llGetAgentList, you can do anything with it you wish.  If you wanted to filter it for distance, for example, you could use llGetObjectDetails in a loop:

 

integer i;while (i < llGetListLength(gAllAvsDetected)) // That's your starting list{    key Av = llList2Key(gAllAvsDetected,i);    vector Pos = llList2Vector(llGetObjectDetails(Av,[OBJECT_POS]),0);    if (llVecDist(Pos,llGetPos()) < 60.0)    {        gCloseAvs += [Av];  // Here's your filtered list    }    ++i;}

If you want to filter it for something else, use the appropriate function in place of llGetObjectDetails.

Once you have the list, or while you are filtering it, you can also build a parallel list of avatar names to use in your dialog box.  Your llDialog function has the form

llDialog(llGetOwner()," \n Pick one! (or whatever message you want)", gAvatarNames,gChan);

where gAvatarNames is the list of names you made while filtering the gAllAvsDetected list.  Then you use the listen event to do something with each of the responses.  Take a look at http://wiki.secondlife.com/wiki/Dialog_Menus for a good overview of how to do it.  Things start to get a wee bit hairy if you have more than 12 buttons in a dialog menu, or if the labels are long enough that you need to use numbered buttons, but you'll find a selection of good scripts in the LSL Scripting Library that deal with those situations.

 EDIT:  Ooops.  Typed too fast and didn't increment my loop.  :smileyembarrassed:

OK, EDIT again (Thank you, Brian): Fixed the distance bit.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Right, ok. Again, thank you very much for all the help with this. ^_^

 

Though, one or two issues persist. I've followed your advice here, used the filter below to do distance as for the time being that's the main one I'm focusing on for this. Though the gCloseAvs list doesn't seem to actually generate the list, I seem to just get an error "Name not defined within scope" Regarding that specific line.

Is that generating the list name  for the if (Dist < 60) filter? Or is that a part I've mistaken and need to define myself? xD

 

Regarding the whole more than 12 button issue, yeah, I've noticed as much. That's another part I'm going to work on later, though not focusing on it for the time being xD

Link to comment
Share on other sites


Juliena wrote:

[ .... ]

Is that generating the list name  for the if (Dist < 60) filter? Or is that a part I've mistaken and need to define myself?
xD
[ .... ]


Well, sort of.  You can get several kinds of information with llGetObjectDetails, and you can get them all at once....

llGetObjectDetails(Av,[OBJECT_POS, OBJECT_NAME,OBJECT_VELOCITY])

 And build a list for each of them, or add them all to a single strided list in the same while loop.

Lists will give you headaches at first, but they do behave logically.  Spend some time with http://wiki.secondlife.com/wiki/Category:LSL_List

Link to comment
Share on other sites

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