Kennethh Yamdev Posted March 12, 2015 Share Posted March 12, 2015 Greetings. I am having a hard time figuring out how to use llSetRegionPos() in my script. Maybe there is a better way to go about this. But I have it where you click the object and llDialog() menu shows up with names of avatars with in range. I want to set it up so that when the name is clicked the object goes to that persons position. But I cannot figure out what I am doing wrong. The script below I had some help writing and im not pro. I am learning and would say I am a moderate scripter. Any tips of help would be great. :) //menu listenerinteger listener;integer sensorChannel;// range and arc for the sensorfloat range = 40.0;float arc = PI;integer i;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 menullSetTimerEvent(20.0);}integer randomNumber(){return (integer)(llFrand(99999.0) * -1);}default{on_rez(integer somettgh){llSensor("","",AGENT,range,arc);}touch_start(integer total_number){//only owner can access the menuif (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){//When person choice is made. Move object to choicellOwnerSay((string) message + " is youre choice.");// llSetRegionPos(); //Need to find out who/where}}}} Link to comment Share on other sites More sharing options...
Xiija Posted March 13, 2015 Share Posted March 13, 2015 you need to set the position by getting the key of the avatar chosen, and getting their object details... and define llSetRgionPos as an integer? kinda like so?.... //menu listenerinteger listener;integer sensorChannel;// range and arc for the sensorfloat range = 40.0;float arc = PI;integer i;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);}integer moved; // llSetRegionPos is an integer.default{ on_rez(integer somettgh) { llSensor("","",AGENT,range,arc); } 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 index = llListFindList(avatarsNames,[message]); if (index > -1) { //When person choice is made. Move object to choice // the names & keys should share the same index since they are added simultaneously key chosenKey = llList2Key(avatarsKeys,index); list details = llGetObjectDetails(chosenKey, ([ OBJECT_POS]) ); vector movePos = llList2Vector(details,0); llOwnerSay((string) message + " is youre choice."); moved = llSetRegionPos(movePos); //you can OwnerSay an error if moved == 0 } } }} you can also use MoveToTarget for this ... http://wiki.secondlife.com/wiki/LlMoveToTarget 1 Link to comment Share on other sites More sharing options...
Kennethh Yamdev Posted March 15, 2015 Author Share Posted March 15, 2015 Ah that works perfect. I had thought that the same key and name I got for llDialog would have worked but I did not think to set another integer. and I see you mentioned llMoveToTarget - That could work too, Ill slide that in there and see what I think. Probably get the same results but hey, it helps practice. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 16, 2015 Share Posted March 16, 2015 Kennethh Yamdev wrote: Ah that works perfect. I had thought that the same key and name I got for llDialog would have worked but I did not think to set another integer. Just to clarify, llSetRegionPos() requires a vector as an argument and returns an integer -- either TRUE (1) or FALSE (0) -- depending on whether the function succedes in moving the object to the target position. You can, if you wish, say something like if(llSetRegionPos(movePos){ //if I have successfully moved to movePos. //do something } else {//Oops! movePos is not an accessible destination for some reason. //do some error handling } but it's not compulsory. Link to comment Share on other sites More sharing options...
Recommended Posts
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