Jump to content
Sign in to follow this  
Ackley Bing

Basic Sim Status Button Indicator HUD

Recommended Posts

// 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);
    }
}

 

  • Like 1

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...