Jump to content

LeonissiaLoc

Resident
  • Posts

    24
  • Joined

  • Last visited

Posts posted by LeonissiaLoc

  1. Can llSetLinkPrimitiveParamsFast(); be used inside a timer function to make the base of the turret track the avatar selected in the dialogue? Note: the base is a separate prim in the link set and the barrel isn't the root prim. They are both connected to a separate block.

  2. What can I use to get the turret to not shoot the owner or the house, but only the target? Something that will make the turret stop shooting on the timer and then continue shooting after the obstacle is no longer in the way.

  3. Is there a way to have two timers in a script like this:

    integer index;
    default
    {
        state_entry()
        {
            llSay(0, "Hello, Avatar!");
        }
    
        touch_start(integer total_number)
        {
            llSay(0, "Touched.");
        }
        timer()
        {
        }
        timer(index)
        {
        }
    }
    

     

  4. 1 minute ago, Rolig Loon said:

    This morning at 7:30.  And then I lost it over breakfast.

    In fact, it never "clicks".  If it did, it would be terribly boring.  As I said earlier (or maybe in a different thread) scripting is an exercise in logic.  It's about creating and solving puzzles.  When the puzzles stop being slightly beyond my ability, I figure I have probably set my sights too low, so it's time to find harder puzzles.   Fortunately, there's no lack there.

    We can be glad there is an endless amount of puzzles to solve with this. That's interesting.

  5. I defined integer index; in the global variable and now it looks at the right avatar when I select it. I had to study LSL Variables to figure out how to do it. I was just stressing out over it because it seemed impossible to define index as a global variable and then change it later in the script. Thank you for your help, I couldn't have figured that out without it. It was a lesson to go back to basics. I will do further testing to make sure everything works right.

     

  6. 1 hour ago, Rolig Loon said:

    You already did that.  That's why you wrote

     

    and the following test in the listen event.  Remember?  Put an llOwnerSay test right after 

     

    to see whether you're looking at the right one.  If not, then you know where you better start looking for the mistake.

    All this code does is list my avatar first followed by the rest in the list at the same time when I select one from the list:

      integer index = llListFindList(uuid,[]); 
           key kTarget = llList2Key(uuid,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
     llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);

    It does the same thing even before even before the timer starts in the listen event in this bit of code with the llOwnerSay() Test: 

       listen(integer channel, string obj, key id, string message)
        {
            list uuid = llList2ListStrided(Names, 0, -1, 2);
            integer index = llListFindList(Names, [message]);
            if (index != -1)
            {
                 llSetTimerEvent(0.05);
            }
        } 

    I think the problem is somewhere in the listen event or it could be in the sensor event because I have the same issue throughout the entire script. It doesn't zero in on the avatar I select It just keeps going at the avatar sensed first and ignores the one I select. Do I need to rewrite the script again or is there something that I failed to study properly? Could it be something simple that I forgot to include? At this point, I'm not really sure what to do.

  7. 20 minutes ago, Rolig Loon said:

    Right about now, the smart thing to do is insert a bunch of llOwnerSay statements to ask the script to tell you what is actually in your various variables at key points. Use llOwnerSay(llList2CSV(uuid)); to find out what's really in that list, for example.  Chance are pretty good that you are grabbing the wrong list element.  Indexing errors are really common and fortunately really easy to find if you just take time to look at what's in the list.

    When there are avatars in the region, it's returning all keys with llOwnerSay(llList2CSV(uuid)); and all names with llOwnerSay(llList2CSV(Names)); at the same time. What should I do to get it to read only the one I select from the llDialog()?

  8. I don't know what to do to get this thing to work. I studied the strided list and I can select the avatar with just the names list. I put the uuid list in there because I can't get the llLookAt() to work with only one list. At "integer index = llListFindList(uuid,[]);" is the only way to track the avatar selected but my avatar is still the one targeted no matter who I select. How do I know what to look up and study so I can fix this what seems to be an impossible challenge? I looked up the functions, but I don't get this. Thanks for your help, any guidance is appreciated. 

    list Names;
    list uuid;
    default
    {
        state_entry()
        {
            llListen(10, "", llGetOwner(), "");
            llSensorRepeat("", "", AGENT, 96.0, PI, 0.2);
        }
        touch_start(integer detected)
        {
            if (llDetectedKey(0) == llGetOwner())
            {
                llSetTimerEvent(0.0);
                llListenRemove(10);
                llSensorRemove();
                llSensor("","",AGENT,96,PI);
                llDialog(llDetectedKey(0), "Choose an avatar...", Names, 10);
            }  
        }
         sensor(integer allAvatars)
        {
            integer o;
            key Id;
            Names = [];
            uuid = [];
            o = 0;
            while ((o < allAvatars) && (o < 12))
            {
                Id = llDetectedKey(o);
                uuid = uuid + Id;
                Names = Names + llKey2Name(Id);
                o = o+1;
            }
            
        }
        listen(integer channel, string obj, key id, string message)
        {
            list uuid = llList2ListStrided(Names, 0, -1, 2);
            integer index = llListFindList(Names, [message]);
            if (index != -1)
            {
                 llSetTimerEvent(0.05);
            }
        }    
        timer()
        {
            
             integer index = llListFindList(uuid,[]); 
           key kTarget = llList2Key(uuid,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
     llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);
    
    
        } 
    }

     

  9. 4 minutes ago, steph Arnott said:

    The prime part of your script is list manipulation. Lists are fundimental in many scripts. From object givers, yours, rezzers etc. The scanner data in this script is a data gatherer. If you kludge someone elses scripts you will never get anywhere because you are just hammering code with no understanding.

    When I am hammering code, I'm also looking up the functions. I seem to not be able to understand what seems to be abstract. Anything with a practical sense or what I've already reverse engineered I can figure out pretty easily. I guess I need to read the wiki about the functions two million times and ask y'all about it for me to get it to click.

  10. After I study LSL long enough and it clicks, will I be able to program anything I think of? Is it the same for all programming languages? How do you know what to do when you get stuck for lack of knowledge and don't know what to look up? Do I just ask on here on how to program a billion different scripts until I finally get it? How does all this work? I don't understand why this is so complicated to wrap my head around. How did y'all do it? Thanks for all the help thus far.

  11. 11 hours ago, Rolig Loon said:

    OK, here's one place to start thinking through the logic.  The function llListFindList looks for the position of its second list parameter in the first list parameter. In this case, your statement

    integer index = llListFindList( avatarsNames ,[]);

    means "Find the position of [] in the list avatarsNames."  That's going to be difficult, because [] is an empty list, so index will have the value -1, meaning "not there".  In another sense, the integer -1 means "the last element in the list."  So, when you use index in the next two statements, you will be looking for the last element in avatarsNames.  That's almost certainly not what you want to do.  To script it to do what you do want, however, means doing a major rewrite of the rest of the script.  The avatar that you really want to target is the one you will identify in the llDialog.  The answer to that query, though, will be in the listen event, where you haven't provided any code to receive it.  And so it goes.  Steph has offered an interesting suggestion that will probably make it easier to keep track of matched variables but is not really at the heart of your major issues here.  There are other things like that that you should probably address too.  For now, though, the simple answer is that the reason it's only targeting you is that your script seems to have used that definition of index to point at the last person on the detected list.

    It's hard to know where to start, except to say that you would be better off starting fresh, writing your own script instead of trying to modify someone else's.  Once of the most basic rules is "don't use someone else's code unless you understand exactly what it does."

    I got my new script to do the basic select avatars and use one list instead of two. What do I need to study to get the listen event to receive the avatar tracking info when I select an avatar?

  12. 6 hours ago, Qie Niangao said:

    I'm sorry to say this, but you need to commit to learning more about scripting. You can't just post the same script in different threads expecting people to change it for you. If you just want a turret script you might either buy one, find one that actually works, or hire somebody to make one for you. If on the other hand you want to learn how to script one yourself, you're in the right place, but I don't think you'll get satisfactory results without investing a little more effort in understanding how the scripts you're posting actually work -- then you could ask about what specifically isn't working with your changes.

    Of course, if you keep trying, somebody may post a script that (accidentally) does exactly what you want. And that would be a failure in this forum because then you wouldn't learn anything about scripting.

    I was trying to do two different things with the same script. The other post was me trying to replace the sensor with llGetAgentList();, but then I discovered that my current script has a targeting issue with the sensor so it probably wouldn't work right with llGetAgentList(); not until I can get the targeting to work with the sensor. I'm trying to use this to learn how all the functions work together and understand how the math works. I'm not asking that anyone do the work for me. I'm looking for help kinda like what I found in this example. I just don't know how to speak LSL effectively yet. I understand a lot of the logic part, but it's the math that is stumping me the most. I keep looking and looking at the script, researching the different functions and I still can't get my head around it. I may be pushing myself a little too much and I'm just missing something. If this is the wrong way to go about asking for help, please let me know. I don't want to come off like I'm trying to get y'all to do the work for me, I want to learn how this works. Any advice is appreciated and I understand beginners like me make a lot of mistakes and y'all probably get a bunch of people trying to get ya'll to do the work for them, I don't want to be like that. Thank you.

  13. How can I get this to target another avatar instead of me when I select a  foreign target? I tried a lot of stuff with it and can't get it to work. Thanks.

     

     

     

    integer listener;
    integer sensorChannel; 
    list avatarsKeys;
    list avatarsNames;
    integer touched;
    menu(key user,integer channel,string title,list buttons)
    {
        listener = llListen(channel,"","","");
        llDialog(user,title,buttons,channel);
    }
    integer randomNumber()
    {
        return (integer)(llFrand(99999.0) * -1);
    }
    default
    {
        touch_start(integer total_number)
        {
            if (llDetectedKey(0) == llGetOwner())
            {
                llSensor("","",AGENT,96,PI);
            }
            
        }
        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)
            {
                llSetTimerEvent(0.05);
            }         
        }
      touch(integer total_number)
        {
            llSetTimerEvent(0.0);
        }
        timer()
        {
           integer index = llListFindList(avatarsNames,[]);
           key kTarget = llList2Key(avatarsKeys,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
     llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);
    list hit = llCastRay(vPos, vTargetPos, []);
    if( llKey2Name(llList2Key(hit, 0)) != "RC" )
    {
        llRezObject("bullet", llGetPos()+<0,0,3>*llGetRot(),<0,0,20>*llGetRot(),llGetRot(),0);
    }
    if( llGetOwnerKey(llList2Key(hit, 0)) == llGetOwner() )
    {
       return;
    }
        } 

  14. I found this script that does the basics. Now I'm trying to add X and Y coordinates to detected avatars.

    I came across this on the wiki:

    vector vec;
    float x = vec.x;
    float y = vec.y;
    float z = vec.z;

    So I added it to this script I found under llGetAgentList() under a Google Search:

    Untouched Script:

    // Tiaeld Tolsen @ TT Industries - llGetAgentList sim-wide radar/Radar de todo el sim de llGetAgentList
     
    //Based in the new llGetAgentList LSL Function (https://jira.secondlife.com/browse/SVC-6427) this is a little 
    //gadget capable to work as an (almost)zero-lag sim-wide radar. Currently, llGetAgentList is only available on the 
    //3 RC Simulator Channels (Magnum, BlueSteel, LeTigre) and it will be hopely deployed for the rest of the grid in a 
    //couple of days.
    //This script can't be sold and any variation of it must contain my name as the original creator.
    //More info at: http://creativecommons.org/licenses/by-nc-sa/3.0/
    //----------------------------------------------------------------------------------
    //Basado en la nueva función de LSL llGetAgentList (https://jira.secondlife.com/browse/SVC-6427) este pequeño 
    //aparato puede funcionar como un radar para todo el sim con (casi) cero lag. Actualmente, llGetAgentList sólo está 
    //disponible en los 3 canales RC (Magnum, BlueSteel, LeTigre) y esperemos que sea repartido al resto del grid en un 
    //par de días.
    //Este script no puede ser vendido y cualquier variación del mismo debe contener mi nombre como el creador original.
    //Más información en: http://creativecommons.org/licenses/by-nc-sa/3.0/
     
     
    //We'll need this later / Necesitaremos esto después
    list lTemp;
    list lTemp2;
    integer iTemp;
    integer iPrims;
    integer iOn;
     
     
     
    //WARNING: Not-so begineer-scripter friendly code ahead, be careful.
    //CUIDADO: Código no tan amigable para scripters novatos adelante, tener cuidado.
     
    clean() { //We clean the remaining cells. / Limpiamos las celdas restantes.
        llSetLinkPrimitiveParamsFast(LINK_ALL_OTHERS, [PRIM_TEXT, "", <1., 1., 1.>, 1.]);
    }
     
    default {
        state_entry() {
            clean();
            llSetText("TT Industries\nSimwide Radar\nOFF", <1., .2, .2>, 1.);
     
            //We'll need this to iterate across all the prims.
            //Necesitaremos esto para recorrer todos los prims.
            iPrims = llGetNumberOfPrims();
        }
     
        touch_start(integer n) {
            if(iOn = !iOn) {
                llOwnerSay("Radar ON");
                llSetText("TT Industries\nSimwide Radar\nON", <.6, .8, 0.>, 1.);
     
                //This is a reasonable time to the script to do it's job.
                //Es un tiempo razonable para dejar trabajar al script.
                llSetTimerEvent(.2);
            } else {
                llOwnerSay("Radar OFF");
                llSetText("TT Industries\nSimwide Radar\nOFF", <1., .2, .2>, 1.);
                llSetTimerEvent(0.);
                clean();
            }
        }
     
        timer() {
            //This is where magic start, thanks to the new llGetAgentList.
            //Aquí empieza la magia, gracias al nuevo llGetAgentList.
            lTemp = (lTemp = []) + (lTemp2 = []) + llGetAgentList(AGENT_LIST_REGION, []);
            iTemp = lTemp!=[];
     
            //In case we got some kind of error, stop everything.
            //En caso de tener algún error, paramos todo.
            if(llGetListEntryType(lTemp, 0)==TYPE_STRING) {
                llOwnerSay("Error: " + llList2String(lTemp, 0));
                iOn = FALSE;
                llSetTimerEvent(0.);
                return;
            }     
           
            //We start filling our new list with the name and distance from ourselves.
            //Empezamos llenando nuestra nueva lista con los nombres y la distancia hacia nosotros.
            while(iTemp--) 
        
                lTemp2 = [llVecDist(llList2Vector(llGetObjectDetails(llList2Key(lTemp, iTemp), [OBJECT_POS]), 0), llGetPos()), llKey2Name(llList2Key(lTemp, iTemp))] + lTemp;
           
            //Since results are unsorted, we sort them.
            //Ya que los resultados están desordenados, los ordenamos.
            lTemp2 = llListSort(lTemp2, 2, TRUE);
     
            //If there are more results than cells, we cap their number.
            //Si hay más resultados que celdas, cortamos su número.
            if((iTemp = lTemp!=[]) > iPrims) iTemp = iPrims;
     
            //We start drawing every cell with our info.
            //Empezamos a dibujar cada celda con nuestra información
            while(--iTemp) 
                llSetLinkPrimitiveParamsFast(iTemp+1, [PRIM_TEXT, llList2String(lTemp2, (iTemp*2)+1) + ": " + (string)llList2Integer(lTemp2, iTemp*2) + " m.",<1., 1., 1.>, 1.]);
     
            //We clean remaining cells in linkset.
            //Limpiamos las celdas restantes en el linkset.
            iTemp = lTemp!=[];
            while(iTemp++ < iPrims)
                llSetLinkPrimitiveParamsFast(iTemp,[PRIM_TEXT, "", <1., 1., 1.>, 1.]);
        }
     
        //Update the interface in case we need it.
        //Limpiamos la interface en caso lo necesitemos.
        on_rez(integer s) {
            clean();
        }
     
        changed(integer change) {
            if(change & CHANGED_REGION) clean();
            else if(change & CHANGED_LINK) iPrims = llGetNumberOfPrims();
        }
    }

    Touched Script:

    // Tiaeld Tolsen @ TT Industries - llGetAgentList sim-wide radar/Radar de todo el sim de llGetAgentList
     
    //Based in the new llGetAgentList LSL Function (https://jira.secondlife.com/browse/SVC-6427) this is a little 
    //gadget capable to work as an (almost)zero-lag sim-wide radar. Currently, llGetAgentList is only available on the 
    //3 RC Simulator Channels (Magnum, BlueSteel, LeTigre) and it will be hopely deployed for the rest of the grid in a 
    //couple of days.
    //This script can't be sold and any variation of it must contain my name as the original creator.
    //More info at: http://creativecommons.org/licenses/by-nc-sa/3.0/
    //----------------------------------------------------------------------------------
    //Basado en la nueva función de LSL llGetAgentList (https://jira.secondlife.com/browse/SVC-6427) este pequeño 
    //aparato puede funcionar como un radar para todo el sim con (casi) cero lag. Actualmente, llGetAgentList sólo está 
    //disponible en los 3 canales RC (Magnum, BlueSteel, LeTigre) y esperemos que sea repartido al resto del grid en un 
    //par de días.
    //Este script no puede ser vendido y cualquier variación del mismo debe contener mi nombre como el creador original.
    //Más información en: http://creativecommons.org/licenses/by-nc-sa/3.0/
     
     
    //We'll need this later / Necesitaremos esto después
    list lTemp;
    list lTemp2;
    integer iTemp;
    integer iPrims;
    integer iOn;
     
     
     
    //WARNING: Not-so begineer-scripter friendly code ahead, be careful.
    //CUIDADO: Código no tan amigable para scripters novatos adelante, tener cuidado.
     
    clean() { //We clean the remaining cells. / Limpiamos las celdas restantes.
        llSetLinkPrimitiveParamsFast(LINK_ALL_OTHERS, [PRIM_TEXT, "", <1., 1., 1.>, 1.]);
    }
     
    default {
        state_entry() {
            clean();
            llSetText("TT Industries\nSimwide Radar\nOFF", <1., .2, .2>, 1.);
     
            //We'll need this to iterate across all the prims.
            //Necesitaremos esto para recorrer todos los prims.
            iPrims = llGetNumberOfPrims();
        }
     
        touch_start(integer n) {
            if(iOn = !iOn) {
                llOwnerSay("Radar ON");
                llSetText("TT Industries\nSimwide Radar\nON", <.6, .8, 0.>, 1.);
     
                //This is a reasonable time to the script to do it's job.
                //Es un tiempo razonable para dejar trabajar al script.
                llSetTimerEvent(.2);
            } else {
                llOwnerSay("Radar OFF");
                llSetText("TT Industries\nSimwide Radar\nOFF", <1., .2, .2>, 1.);
                llSetTimerEvent(0.);
                clean();
            }
        }
     
        timer() {
            //This is where magic start, thanks to the new llGetAgentList.
            //Aquí empieza la magia, gracias al nuevo llGetAgentList.
            lTemp = (lTemp = []) + (lTemp2 = []) + llGetAgentList(AGENT_LIST_REGION, []);
            iTemp = lTemp!=[];
     
            //In case we got some kind of error, stop everything.
            //En caso de tener algún error, paramos todo.
            if(llGetListEntryType(lTemp, 0)==TYPE_STRING) {
                llOwnerSay("Error: " + llList2String(lTemp, 0));
                iOn = FALSE;
                llSetTimerEvent(0.);
                return;
            }  
            
           vector pos;
    		float x = vec.x;
    		float y = vec.y;
    		float z = vec.z;
            
            //We start filling our new list with the name and distance from ourselves.
            //Empezamos llenando nuestra nueva lista con los nombres y la distancia hacia nosotros.
            while(iTemp--) 
        
                lTemp2 = [llVecDist(llList2Vector(llGetObjectDetails(llList2Key(lTemp, iTemp), [OBJECT_POS]), 0), pos), llKey2Name(llList2Key(lTemp, iTemp))] + lTemp;
           
            //Since results are unsorted, we sort them.
            //Ya que los resultados están desordenados, los ordenamos.
            lTemp2 = llListSort(lTemp2, 2, TRUE);
     
            //If there are more results than cells, we cap their number.
            //Si hay más resultados que celdas, cortamos su número.
            if((iTemp = lTemp!=[]) > iPrims) iTemp = iPrims;
     
            //We start drawing every cell with our info.
            //Empezamos a dibujar cada celda con nuestra información
            while(--iTemp) 
                llSetLinkPrimitiveParamsFast(iTemp+1, [PRIM_TEXT, llList2String(lTemp2, (iTemp*2)+1) + ": " + (string)llList2Integer(lTemp2, iTemp*2) + " m.",<1., 1., 1.>, 1.]);
     
            //We clean remaining cells in linkset.
            //Limpiamos las celdas restantes en el linkset.
            iTemp = lTemp!=[];
            while(iTemp++ < iPrims)
                llSetLinkPrimitiveParamsFast(iTemp,[PRIM_TEXT, "", <1., 1., 1.>, 1.]);
        }
     
        //Update the interface in case we need it.
        //Limpiamos la interface en caso lo necesitemos.
        on_rez(integer s) {
            clean();
        }
     
        changed(integer change) {
            if(change & CHANGED_REGION) clean();
            else if(change & CHANGED_LINK) iPrims = llGetNumberOfPrims();
        }
    }

    I tried to replace llGetPos() with pos, but I'm not sure how to integrate x and y coordinates. The script already does distance. Later I'm gonna try to get the linked spheres to track the avatars in a cube frame. Can someone give me some advice on this? I'm trying to learn how to do this, thank you.

  15. So far I have this, but I'm having trouble figuring out the avatarsName part.

    integer listener;
    integer sensorChannel;
    list avatarsKeys;
    list avatarsNames; 
    integer touched;
    menu(key user,integer channel,string title,list buttons)
    {
        listener = llListen(channel,"","","");
        llDialog(user,title,buttons,channel);
    }
    integer randomNumber()
    {
        return (integer)(llFrand(99999.0) * -1);
    }
    default
    {
        touch_start(integer total_number)
        {
            list avatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []);
            integer numOfAvatars = llGetListLength(avatarsInRegion);
     
            // if no avatars, abort avatar listing process and give a short notice
            if (!numOfAvatars)
            {
                llOwnerSay("No avatars found within the region!");
                return;
            }
            integer i;
            key tempId;
            avatarsKeys = [];
            avatarsNames = [];
            i = 0;
            integer index;
            while ((i < total_number) && (i < 12))
            {
                tempId = llDetectedKey(i);
                avatarsKeys = avatarsKeys + tempId;
                avatarsNames = avatarsNames + llKey2Name(tempId);
                i = i+1;
                key id = llList2Key(avatarsInRegion, index);
                string name = llKey2Name(id);
     
                llOwnerSay(name + " [ " + (string)id + " ]");
                ++index;
            }
            sensorChannel = randomNumber();
            menu(llGetOwner(),sensorChannel,"Select an avatar...",avatarsInRegion);
        }
        listen(integer channel,string name,key id,string message)
        {
            if (channel == sensorChannel)
            {
                llSetTimerEvent(0.05);
            }   
            }touch(integer total_number)
        {
            llSetTimerEvent(0.0);
            llListenRemove(0);
        }
        timer()
        {
           integer index = llListFindList(avatarsNames,[]);
           key kTarget = llList2Key(avatarsKeys,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
     llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);
    list hit = llCastRay(vPos, vTargetPos, []);
    if( llKey2Name(llList2Key(hit, 0)) != "RC" )
    {
        llRezObject("bullet", llGetPos()+<0,0,3>*llGetRot(),<0,0,20>*llGetRot(),llGetRot(),0);
    }
    if( llGetOwnerKey(llList2Key(hit, 0)) == llGetOwner() )
    {
       return;
    }      
        }
    }

     

  16. How can I get this to detect avatars using llGetAgentList? 

    integer listener;
    integer sensorChannel; 
    list avatarsKeys;
    list avatarsNames;
    integer touched;
    menu(key user,integer channel,string title,list buttons)
    {
        listener = llListen(channel,"","","");
        llDialog(user,title,buttons,channel);
    }
    integer randomNumber()
    {
        return (integer)(llFrand(99999.0) * -1);
    }
    default
    {
        touch_start(integer total_number)
        {
            if (llDetectedKey(0) == llGetOwner())
            {
                llSensor("","",AGENT,96,PI);
            }
            
        }
        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)
            {
                llSetTimerEvent(0.05);
            }         
        }
      touch(integer total_number)
        {
            llSetTimerEvent(0.0);
        }
        timer()
        {
           integer index = llListFindList(avatarsNames,[]);
           key kTarget = llList2Key(avatarsKeys,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
     llLookAt(vPos + (vTargetPos + <0.0, 0.0, 0.0> - vPos) / llGetRootRotation(), 1.0, 0);
    list hit = llCastRay(vPos, vTargetPos, []);
    if( llKey2Name(llList2Key(hit, 0)) != "RC" )
    {
        llRezObject("bullet", llGetPos()+<0,0,3>*llGetRot(),<0,0,20>*llGetRot(),llGetRot(),0);
    }
    if( llGetOwnerKey(llList2Key(hit, 0)) == llGetOwner() )
    {
       return;
    }
        } 
    } 

     

  17. 1 hour ago, Wulfie Reanimator said:

    @LeonissiaLoc There is no real communication needed between the two objects.

    For example, I have a nondescript object moving around in a circle (1 degree every 0.022 seconds). It only has code for moving itself, it does not listen or send messages.

    I then have this script in a worn attachment (also updating the camera params every 0.022 seconds, but you do not need to do it this often):

    
    key uuid = "c6e3e94d-9586-ff64-2f52-bae2b76a25b9";
    
    default
    {
        state_entry()
        {
            llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
        }
    
        run_time_permissions(integer perm)
        {
            llSetTimerEvent(0.022);
        }
    
        timer()
        {
            // Get the remote object's position and rotation.
            list data = llGetObjectDetails(uuid, [OBJECT_POS, OBJECT_ROT]);
            vector pos = llList2Vector(data, 0);
            rotation rot = llList2Rot(data, 1);
    
            llSetCameraParams([
                // Begin controlling the camera and prevent it from being moved.
                // (Alt-cam will still override this.)
                CAMERA_ACTIVE, TRUE,
                CAMERA_FOCUS_LOCKED, TRUE,
                CAMERA_POSITION_LOCKED, TRUE,
    
                CAMERA_FOCUS, pos,                           // The position the camera will LOOK at.
                CAMERA_POSITION, pos + (<0, -2, 1> * rot)    // The position the camera will BE at.
            ]);
        }
    
        touch_start(integer n)
        {
            llClearCameraParams();
            llSetTimerEvent(0);
        }
    }

    Note that I used "<0, -2, 1>" as an offset so that the camera would be on the object's right side and slightly above it.

    For testing purposes, you can select on any object or link in Edit Mode and click on the "Copy Keys" button in the General tab of the Edit Tools window. If you were to rez an object and wanted to track that instead, you could get the rezzed object's key through the object_rez event. For any other case, you'd require some kind of custom communication between the objects.

    Thank you very much, this works as intended now.

  18. Will this bit of code communicate to the helicopter from the hud script? I'm not worried if any of the solutions are jerky or not because that can be improved, Thanks.

    focus_on_helicopter()
    {
    
        vector here = llGetPos();
        llSetCameraParams([CAMERA_ACTIVE, TRUE,
            CAMERA_BEHINDNESS_ANGLE, 0.0,
            CAMERA_BEHINDNESS_LAG, 0.5,
            //CAMERA_DISTANCE, 4.0,
            CAMERA_DISTANCE, 6.0,
            CAMERA_PITCH, 10.0,
            // CAMERA_FOCUS,
            CAMERA_FOCUS_LAG, 0.05,
            CAMERA_FOCUS_LOCKED, FALSE,
            CAMERA_FOCUS_THRESHOLD, 0.0,
            // CAMERA_POSITION,
            CAMERA_POSITION_LAG, 0.5,
            CAMERA_POSITION_LOCKED, FALSE,
            CAMERA_POSITION_THRESHOLD, 0.0,
            //CAMERA_FOCUS_OFFSET, <0,0,3>];
            CAMERA_FOCUS_OFFSET, <0,0,0>]);
    }

    This is the Script in the Heli:

    default{
        on_rez(integer r){
            llResetScript();
        }
         state_entry()
        {
            llListen(3, "","", ""); 
        }
        listen(integer channel, string name, key id, string message)
        {
             if (llGetOwner() != llGetOwnerKey(id))
            {return;}
            
            if(message == "on")
            {
              llSetTimerEvent(0.05);
            }
              
            if (message == "off")  
            {
                llSetTimerEvent(0.0);   
            }
            
            }
     timer()
        {
          llRegionSay(4,(string)llGetPos()); 
        }
    }

     

×
×
  • Create New...