//Touch and get near avatars in a dialog menu. //By Kahiro Watanabe //GPL share it! //menu listener integer listener; integer sensorChannel; // range and arc for the sensor float range = 15.0; float arc = PI; list avatarsKeys; list avatarsNames; menu(key user,integer channel,string title,list buttons) { listener = llListen(channel,"","",""); llDialog(user,title,buttons,channel); //remove listener if there's no activity in menu llSetTimerEvent(20.0); } integer randomNumber() { return (integer)(llFrand(99999.0) * -1); } default { touch_start(integer total_number) { //only owner can access the menu if (llDetectedKey(0) == llGetOwner()) { llSensor("","",AGENT,range,arc); } } sensor(integer total_number) { integer i; key tempId; avatarsKeys = []; avatarsNames = []; i = 0; while ((i < total_number) && (i < 12)) { tempId = llDetectedKey(i); avatarsKeys = avatarsKeys + tempId; avatarsNames = avatarsNames + llKey2Name(tempId); i = i+1; } sensorChannel = randomNumber(); menu(llGetOwner(),sensorChannel,"Select an avatar...",avatarsNames); } listen(integer channel,string name,key id,string message) { if (channel == sensorChannel) { integer pos = llListFindList(avatarsNames,[message]); if (pos > -1) { llSay(0,message + "'s key is " + llList2String(avatarsKeys,pos)); } } } timer() { llListenRemove(listener); llSetTimerEvent(0.0); } }
This simple script can be controlled only by owner, it will generate a list of near avatars and put it in a menu, when the user selects one it will show its key. You can do useful stuff like give an object or animate it, etc etc etc.