Difference between revisions of "Basic Sim Status Button Indicator HUD"

From Second Life Wiki
Jump to: navigation, search
(Created page with "<lsl> // Generic Sim Status Button / Indicator // HUD / 1 prim // by Ackley Bing // December 2012 // // A HUD button for remote monitoring of sims. // Color indicates the sim sta…")
 
Line 43: Line 43:
 
     {
 
     {
 
         if(llGetTime()<5.0 && homeregion != "") datarequestID=llRequestSimulatorData(homeregion,DATA_SIM_STATUS);
 
         if(llGetTime()<5.0 && homeregion != "") datarequestID=llRequestSimulatorData(homeregion,DATA_SIM_STATUS);
         else llDialog(llGetOwner(), "Is "+llGetRegionName()+" your home?", ["Yes","No"], (listenhandle = llListen(1, "", llGetOwner(), "")));
+
         else llDialog(llGetOwner(), "Monitor Sim Status for "+llGetRegionName()+"?", ["Yes","No"], (listenhandle = llListen(1, "", llGetOwner(), "")));
 
     }
 
     }
 
     listen(integer channel, string name, key id, string message)
 
     listen(integer channel, string name, key id, string message)
Line 52: Line 52:
 
             datarequestID=llRequestSimulatorData(homeregion=llGetRegionName(),DATA_SIM_STATUS);
 
             datarequestID=llRequestSimulatorData(homeregion=llGetRegionName(),DATA_SIM_STATUS);
 
         }
 
         }
         if (message=="No")
+
         if (message=="No" && homeregion=="")
 
         {
 
         {
 
             llSetTimerEvent(0.0);
 
             llSetTimerEvent(0.0);

Revision as of 11:47, 16 December 2012

<lsl> // Generic Sim Status Button / Indicator // HUD / 1 prim // by Ackley Bing // December 2012 // // A HUD button for remote monitoring of sims. // Color indicates the sim status // Green = SIM available // When the sim goes down it turns red/black // // To use put this in a prim and attach to your preferred HUD location. // Go to the sim you want to monitor and and click the prim // Click and HOLD the hud button to choose another sim. // // Modify // Attach / Connect this to your HUD/Vehicle/etc any way you like.

integer listenhandle; string homeregion; key datarequestID;

SetHomeButtonColor(string data) {

   if ( data == "up" ) llSetPrimitiveParams( [ PRIM_COLOR, 4, <0.0,1.0,0.0>, 1.0 ] ); // set color to green
   else if ( data == "down" ) llSetPrimitiveParams( [ PRIM_COLOR, 4, <1.0,0.0,0.0>, 1.0 ] ); // set color to red
   else if ( data == "starting" || data == "stopping" ) llSetPrimitiveParams( [ PRIM_COLOR, 4, <1.0,1.0,0.0>, 1.0 ] ); // set color to yellow
   else llSetPrimitiveParams( [ PRIM_COLOR, 4, <0.0,0.0,0.0>, 1.0 ] ); // set color to black

}

default {

   state_entry()
   {
       llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
       SetHomeButtonColor("");
   }
   touch_start(integer n)
   {
       llResetTime();
       llSetTimerEvent(30.0);
   }
   touch_end(integer n)
   {
       if(llGetTime()<5.0 && homeregion != "") datarequestID=llRequestSimulatorData(homeregion,DATA_SIM_STATUS);
       else llDialog(llGetOwner(), "Monitor Sim Status for "+llGetRegionName()+"?", ["Yes","No"], (listenhandle = llListen(1, "", llGetOwner(), "")));
   }
   listen(integer channel, string name, key id, string message)
   {
       if (message=="Yes")
       {
           llSetTimerEvent(30.0);
           datarequestID=llRequestSimulatorData(homeregion=llGetRegionName(),DATA_SIM_STATUS);
       }
       if (message=="No" && homeregion=="")
       {
           llSetTimerEvent(0.0);
           SetHomeButtonColor(homeregion="");
       }
   }
   timer()
   {
       if (listenhandle) llListenRemove(listenhandle--);
       if (homeregion!="") llRequestSimulatorData(homeregion,DATA_SIM_STATUS);
   }
   dataserver(key requested, string data)
   {
       if (requested==datarequestID) llOwnerSay("http://maps.secondlife.com/secondlife/"+llEscapeURL(homeregion)+" is "+data+(string)(datarequestID=""));
       SetHomeButtonColor(data);
   }
   run_time_permissions(integer perms)
   {
       llTakeControls((perms && PERMISSION_TAKE_CONTROLS)*CONTROL_BACK, TRUE, TRUE);
   }

} </lsl>