Jump to content
Sign in to follow this  
LeonissiaLoc

A Script to Make A 3D Radar That Can Be Linked To A Moving Vehicle

Recommended Posts

I want to make a 3D radar that has the spheres linked to it to track avatars in the entire region. I also want the radar to be linked to a moving vehicle. Plus I want to be able to select the avatars from a dialog and send them an object. How would I go about doing this?

Share this post


Link to post
Share on other sites

If you are looking for someone to write the scripts for you I would suggest that you post in the 'Wanted' sub-forum ... if you want to do it yourself ... check the Wiki to learn what the functions that LSL provide could do.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...