LlRequestSimulatorData

De DigiWiki.

(Différences entre les versions)
 
Ligne 1 : Ligne 1 :
<lsl>
<lsl>
-
// llRequestSimulatorData v0.1 by djphil (BY-BC-SA)
+
string gSimName;
-
 
+
key gStatusQuery;
-
key SIM_POS;
+
string gStatus;
-
key SIM_STATUS;
+
string gRating;
-
key SIM_RATING;
+
key SimPos;
-
       
+
default
default
{
{
-
     touch_start(integer total_number)
+
     state_entry()
 +
    {
 +
        llListen(1, "", "", "");
 +
    }
 +
 +
    listen(integer channel, string name, key id, string mesg)
 +
    {
 +
        gSimName = mesg;
 +
        gStatusQuery = llRequestSimulatorData(gSimName, DATA_SIM_STATUS);
 +
        gRating = llRequestSimulatorData(gSimName, DATA_SIM_RATING);
 +
        SimPos = llRequestSimulatorData(gSimName, DATA_SIM_POS);
 +
    }
 +
 +
    dataserver(key queryId, string data)  
     {
     {
-
         SIM_POS    = llRequestSimulatorData( llGetRegionName(), DATA_SIM_POS);
+
         if (queryId == gStatusQuery)
-
         SIM_STATUS = llRequestSimulatorData( llGetRegionName(), DATA_SIM_STATUS);
+
        {
-
        SIM_RATING = llRequestSimulatorData( llGetRegionName(), DATA_SIM_RATING);
+
            gStatus = data;
 +
        }
 +
        else if (queryId == gRating)
 +
        {
 +
            gRating = data;
 +
         }   
 +
        else
 +
        {
 +
            vector SimPos? = (vector) data;
 +
            llSay(0, gSimName + " (" + gRating + ") " + "(" +
 +
                (string)((integer) SimPos?.x) + ", " +
 +
                (string)((integer) SimPos?.y) + ") is " + gStatus);  
 +
        }
     }
     }
 +
}
 +
</lsl>
-
     dataserver(key QUERY, string DATA)
+
<lsl>
 +
key ahernStatusQuery;
 +
key ahernPosQuery;
 +
default
 +
{
 +
     touch_start(integer total_number)
     {
     {
-
         string TEXT;
+
         ahernStatusQuery = llRequestSimulatorData("ahern", DATA_SIM_STATUS);
-
        if (QUERY == SIM_POS)
+
         ahernPosQuery = llRequestSimulatorData("ahern", DATA_SIM_POS);
-
            TEXT += "\nSIM_POS > " + DATA;
+
-
           
+
-
         if (QUERY == SIM_STATUS)
+
-
            TEXT += "\nSIM_STATUS > " + DATA;
+
-
           
+
-
        if (QUERY == SIM_RATING)
+
-
            TEXT += "\nSIM_RATING > " + DATA;
+
-
        llOwnerSay(TEXT);
+
     }
     }
-
 
+
     dataserver(key queryId, string data)  
-
     changed(integer change)
+
     {
     {
-
         if (change & CHANGED_OWNER) llResetScript();
+
         if (queryId == ahernStatusQuery) {
-
         if (change & CHANGED_REGION) llResetScript();
+
            ahernStatusQuery = "";
 +
            llSay(0, "Status of Ahern: " + data);
 +
         } else if (queryId == ahernPosQuery) {
 +
            ahernPosQuery = "";
 +
            llSay(0, "Ahern's position: " + data);
 +
        }
     }
     }
}
}
</lsl>
</lsl>
 +
Hide objects in PG or unknown regions
Hide objects in PG or unknown regions
<lsl>
<lsl>
Ligne 64 : Ligne 93 :
         if (ItChanged & CHANGED_OWNER)  llResetScript();
         if (ItChanged & CHANGED_OWNER)  llResetScript();
         if (ItChanged & CHANGED_REGION) llResetScript();
         if (ItChanged & CHANGED_REGION) llResetScript();
 +
    }
 +
}
 +
</lsl>
 +
 +
<lsl>
 +
string  email_address = "leproprio@gmail.com";
 +
 +
list    regions = [ "Garmu", "Bruda", "Qrassica", "Broadwater", "Predrow", "Derimon","Kellig",
 +
                    "Melisande", "Osbourne Beach", "Osbourne Walk","Caeshu","Patavium","Maso Ariol",
 +
                    "Henrietta","Sea of Antiquity","Sailor","Deadly Fear","Jieut","Land Of Light","Venn"];
 +
list    list_ids;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSetTimerEvent ( 300 );
 +
    }
 +
 +
    timer()
 +
    {
 +
        integer i;
 +
        key    Id;
 +
        string  region_checked;
 +
       
 +
        integer nb_regions_checked = llGetListLength ( regions ); // nombre de régions
 +
       
 +
        list_ids = [];
 +
       
 +
        for (i = 0; i < nb_regions_checked;  ++i)
 +
        {
 +
            region_checked = llList2String(regions,i);                          // pour une région
 +
            Id = llRequestSimulatorData( region_checked , DATA_SIM_STATUS );    // on effectue la requête
 +
            list_ids += [Id,region_checked];                                    // et on ASSOCIE dans une liste
 +
                                                                                // le couple Id/Région
 +
                                                                                // puisque l'on sait que cette ligne de  code sera
 +
        }                                                                      // lu  AVANT de recevoir les données.....
 +
    }
 +
   
 +
    dataserver(key queryId, string data)
 +
    {
 +
        integer index = llListFindList(list_ids, (list)queryId); // Après on teste l'existence de ID dans la liste....
 +
        if(index  != -1)
 +
        {   
 +
            if (data != "up")  // et son status  et le tour est joué!
 +
                llEmail( email_address, "Alert from Second Life about one of your region ", llList2String(list_ids,index+1) + " is " + data  );
 +
        }
     }
     }
}
}
</lsl>
</lsl>

Version actuelle en date du 6 novembre 2013 à 11:58

string gSimName; 
key gStatusQuery;
string gStatus;
string gRating;
key SimPos;
 
default
{
    state_entry() 
    { 
        llListen(1, "", "", ""); 
    } 
 
    listen(integer channel, string name, key id, string mesg) 
    { 
        gSimName = mesg; 
        gStatusQuery = llRequestSimulatorData(gSimName, DATA_SIM_STATUS); 
        gRating = llRequestSimulatorData(gSimName, DATA_SIM_RATING);
        SimPos = llRequestSimulatorData(gSimName, DATA_SIM_POS);
    }
 
    dataserver(key queryId, string data) 
    {
        if (queryId == gStatusQuery)
        {
            gStatus = data;
        }
        else if (queryId == gRating)
        {
            gRating = data;
        }    
        else 
        {
            vector SimPos? = (vector) data; 
            llSay(0, gSimName + " (" + gRating + ") " + "(" + 
                (string)((integer) SimPos?.x) + ", " + 
                (string)((integer) SimPos?.y) + ") is " + gStatus); 
        }
    }
}
key ahernStatusQuery;
key ahernPosQuery;
default
{
    touch_start(integer total_number)
    {
        ahernStatusQuery = llRequestSimulatorData("ahern", DATA_SIM_STATUS);
        ahernPosQuery = llRequestSimulatorData("ahern", DATA_SIM_POS);
    }
    dataserver(key queryId, string data) 
    {
        if (queryId == ahernStatusQuery) {
            ahernStatusQuery = "";
            llSay(0, "Status of Ahern: " + data);
        } else if (queryId == ahernPosQuery) {
            ahernPosQuery = "";
            llSay(0, "Ahern's position: " + data);
        }
    }
}

Hide objects in PG or unknown regions

key gRateingQuery = NULL_KEY;
 
default
{
    state_entry()
    {
        gRateingQuery = llRequestSimulatorData( llGetRegionName(), DATA_SIM_RATING );
    }
 
    dataserver(key query_id, string data)
    {
        if (query_id == gRateingQuery)
        {
            if (data == "MATURE" || data == "ADULT")
                llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
            else if (data == "UNKNOWN" || data == "PG")
                llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
        }
    }
 
    on_rez(integer Setting) {llResetScript();}
 
    changed(integer ItChanged)
    {
        if (ItChanged & CHANGED_OWNER)  llResetScript();
        if (ItChanged & CHANGED_REGION) llResetScript();
    }
}
string  email_address = "leproprio@gmail.com";
 
list    regions = [ "Garmu", "Bruda", "Qrassica", "Broadwater", "Predrow", "Derimon","Kellig", 
                    "Melisande", "Osbourne Beach", "Osbourne Walk","Caeshu","Patavium","Maso Ariol",
                    "Henrietta","Sea of Antiquity","Sailor","Deadly Fear","Jieut","Land Of Light","Venn"];
list    list_ids;
 
default
{
    state_entry() 
    { 
        llSetTimerEvent ( 300 );
    }
 
    timer()
    {
        integer i;
        key     Id;
        string  region_checked;
 
        integer nb_regions_checked = llGetListLength ( regions ); // nombre de régions
 
        list_ids = [];
 
        for (i = 0; i < nb_regions_checked;   ++i) 
        { 
            region_checked = llList2String(regions,i);                          // pour une région
            Id = llRequestSimulatorData( region_checked , DATA_SIM_STATUS );    // on effectue la requête
            list_ids += [Id,region_checked];                                    // et on ASSOCIE dans une liste 
                                                                                // le couple Id/Région
                                                                                // puisque l'on sait que cette ligne de  code sera 
        }                                                                       // lu  AVANT de recevoir les données.....
    }
 
    dataserver(key queryId, string data) 
    {
        integer index = llListFindList(list_ids, (list)queryId); // Après on teste l'existence de ID dans la liste....
        if(index  != -1)
        {    
            if (data != "up")  // et son status  et le tour est joué!
                llEmail( email_address, "Alert from Second Life about one of your region ", llList2String(list_ids,index+1) + " is " + data  );
        }
    }
}
Outils personnels
  • Cette page a été consultée 984 fois.
donate
Google Ads