Basic Sim Status Button Indicator HUD
Revision as of 23:48, 5 May 2014 by Ackley Bing (talk | contribs)
<lsl> // Generic Sim Status Button Indicator // HUD / 1 prim // by Ackley Bing // January 2013 // // 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 region; key datarequestID;
vector SimStutus2Color(string data) {
if ( data == "up" ) return <0.0,1.0,0.0>; // green else if ( data == "down" ) return <1.0,0.0,0.0>; // red else if ( data == "starting" || data == "stopping" ) return <1.0,1.0,0.0>; // yellow else return <0.0,0.0,0.0>; // black
}
default {
state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); llSetPrimitiveParams([PRIM_COLOR, 4, SimStutus2Color(""), 1.0]); } touch_start(integer n) { llResetTime(); llSetTimerEvent(30.0); } touch_end(integer n) { if(llGetTime()<5.0 && region != "") datarequestID=llRequestSimulatorData(region,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") datarequestID=llRequestSimulatorData(region=llGetRegionName(),DATA_SIM_STATUS); if (message=="No" && region=="") llSetPrimitiveParams([PRIM_COLOR, 4, SimStutus2Color(""), 1.0]); } timer() { if (listenhandle) llListenRemove(listenhandle--); if (region!="") llRequestSimulatorData(region,DATA_SIM_STATUS); } dataserver(key requested, string data) { if (requested==datarequestID) llOwnerSay("http://maps.secondlife.com/secondlife/"+llEscapeURL(region)+" is "+data+(string)(datarequestID="")); llSetPrimitiveParams([PRIM_COLOR, 4, SimStutus2Color(data), 1.0]); } run_time_permissions(integer perms) { llTakeControls((perms && PERMISSION_TAKE_CONTROLS)*CONTROL_BACK, TRUE, TRUE); }
} </lsl>