Difference between revisions of "Basic Sim Status Button Indicator HUD"
Jump to navigation
Jump to search
Ackley Bing (talk | contribs) |
Ackley Bing (talk | contribs) (some fine tuning) |
||
Line 1: | Line 1: | ||
<lsl> | <lsl> | ||
// Generic Sim Status Button | // Generic Sim Status Button Indicator | ||
// HUD / 1 prim | // HUD / 1 prim | ||
// by Ackley Bing | // by Ackley Bing | ||
// | // January 2013 | ||
// | // | ||
// A HUD button for remote monitoring of sims. | // A HUD button for remote monitoring of sims. | ||
Line 17: | Line 17: | ||
integer listenhandle; | integer listenhandle; | ||
string | string region; | ||
key datarequestID; | key datarequestID; | ||
vector SimStutus2Color(string data) | |||
{ | { | ||
if ( data == "up" ) | if ( data == "up" ) return <0.0,1.0,0.0>; // green | ||
else if ( data == "down" ) | else if ( data == "down" ) return <1.0,0.0,0.0>; // red | ||
else if ( data == "starting" || data == "stopping" ) | else if ( data == "starting" || data == "stopping" ) return <1.0,1.0,0.0>; // yellow | ||
else | else return <0.0,0.0,0.0>; // black | ||
} | } | ||
Line 33: | Line 33: | ||
{ | { | ||
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); | llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); | ||
llSetPrimitiveParams([PRIM_COLOR, 4, SimStutus2Color(""), 1.0]); | |||
} | } | ||
touch_start(integer n) | touch_start(integer n) | ||
{ | { | ||
llResetTime(); | llResetTime(); | ||
llSetTimerEvent(30.0); | |||
} | } | ||
touch_end(integer n) | touch_end(integer n) | ||
{ | { | ||
if(llGetTime()<5.0 && region != "") datarequestID=llRequestSimulatorData(region,DATA_SIM_STATUS); | |||
if(llGetTime()<5.0 && | |||
else llDialog(llGetOwner(), "Monitor Sim Status for "+llGetRegionName()+"?", ["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) | ||
{ | { | ||
if (message=="Yes") datarequestID=llRequestSimulatorData( | if (message=="Yes") datarequestID=llRequestSimulatorData(region=llGetRegionName(),DATA_SIM_STATUS); | ||
if (message=="No" && | if (message=="No" && region=="") llSetPrimitiveParams([PRIM_COLOR, 4, SimStutus2Color(""), 1.0]); | ||
} | } | ||
timer() | timer() | ||
{ | { | ||
if (listenhandle) llListenRemove(listenhandle--); | if (listenhandle) llListenRemove(listenhandle--); | ||
if ( | if (region!="") llRequestSimulatorData(region,DATA_SIM_STATUS); | ||
} | } | ||
dataserver(key requested, string data) | dataserver(key requested, string data) | ||
{ | { | ||
if (requested==datarequestID) llOwnerSay("http://maps.secondlife.com/secondlife/"+llEscapeURL( | 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) | run_time_permissions(integer perms) |
Revision as of 19:13, 7 January 2013
<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>