Jump to content

Switch script (ON OFF /SHOW HIDE) HUD problems


arisaie
 Share

You are about to reply to a thread that has been inactive for 496 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

 

 

I am making a script for my HUD that has the outline of the body and you click on the faces to show/hide parts of mesh that you clicked (Clicking lower leg hides mesh on lower leg)

I thought everything is OK until I noticed that I actually need to click another HUD face  2 times. 1st click hides the part I want no problem, but then to hide another part I have to click the other face 2 times. I suspect the problem is due to the switch script I am using. It is the normal switch script you can find when googling for light switch script.

Another issue is, sometimes the HUD change is opposite - i click the HUD to hide the face, but the mesh face appears. I click the HUD to unhide the face and the mesh face disappears.

3rd issue is I have no idea how to incorporate the glow pattern into the hide face script. I figured out how to hide the static glow when hiding a mesh face (glow remains even when the mesh alpha is 0). But the glow pattern uses a timer and I have no idea how to use it. (I might drop the glow pattern if its too difficult)

 

First script is the HUD, 2nd script is the mesh listener. Any help appreciated.

integer dChannel;
integer lHandle;
key id;
key AvatarKey;
integer isOne;

default
{
     changed(integer change)
    {
        if(change & CHANGED_OWNER) 
        {
            llResetScript();
        }
    }
    
    
    attach(key AvatarKey)
    
    {
        AvatarKey = llGetOwner();
        llRequestPermissions(AvatarKey, PERMISSION_ATTACH);

    }
    
     run_time_permissions(integer perm)
    {
 AvatarKey = llGetOwner();
  llRequestPermissions(AvatarKey, PERMISSION_ATTACH);
        }
    
    

    touch_start(integer num_detected)
    {
                 //dChannel = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF);
 isOne = !isOne;
dChannel = 1;
        integer link = llDetectedLinkNumber(0);
        integer face = llDetectedTouchFace(0);
        AvatarKey = llGetOwner();
        integer perm;

        if (face == TOUCH_INVALID_FACE)
            llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
        else
        {
            // store the original color
            list   colorParams   = llGetLinkPrimitiveParams(link, [PRIM_COLOR, face]);
            vector originalColor = llList2Vector(colorParams, 0);


//WHITE---------------------------------------------------------------------
             if (face == 4 && link == 1)
            llRegionSay(dChannel, "StarSetColorWhite");

            
//RED---------------------------------------------------------------------
            
            if (face == 3 && link == 1)
            llRegionSay(dChannel, "StarSetColorRed");

//ORANGE---------------------------------------------------------------------
            
           if (face == 2 && link == 1)
            llRegionSay(dChannel, "StarSetColorOrange");  
            
//YELLOW---------------------------------------------------------------------
            
           if (face == 5 && link == 1)
            llRegionSay(dChannel, "StarSetColorYellow");  
            
//Green---------------------------------------------------------------------
            
           if (face == 0 && link == 1)
            llRegionSay(dChannel, "StarSetColorGreen");  
            
//Torquise---------------------------------------------------------------------
            
           if (face == 4 && link == 2)
            llRegionSay(dChannel, "StarSetColorTorquise");  

//Blue---------------------------------------------------------------------
            
           if (face == 1 && link == 2)
            llRegionSay(dChannel, "StarSetColorBlue");  
            
//Purple---------------------------------------------------------------------
            
           if (face == 3 && link == 2)
            llRegionSay(dChannel, "StarSetColorPurple");  
            
//Pink---------------------------------------------------------------------
            
           if (face == 2 && link == 2)
            llRegionSay(dChannel, "StarSetColorPink");  
            
//Black---------------------------------------------------------------------
            
           if (face == 0 && link == 2)
            llRegionSay(dChannel, "StarSetColorBlack");  


//---------------------------------------------------------------------
//Glow---------------------------------------------------------------------
     
            
             if (face == 0 && link == 3)
            llRegionSay(dChannel, "GlitterGlow0");
             if (face == 1 && link == 3)
            llRegionSay(dChannel, "GlitterGlow15");
             if (face == 2 && link == 3)
            llRegionSay(dChannel, "GlitterGlow30");
             if (face == 3 && link == 3)
            llRegionSay(dChannel, "GlitterGlowPulse");
            
            
//ALPHA---------------------------------------------------------------------
        
             if (face == 0 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideLowerLegLeft");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 0, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideLowerLegLeft");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 0, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
                 if (face == 1 && link == 16)
           
            
        {
            if(isOne)
            {
            llRegionSay(dChannel, "ShowHideLowerLegRight");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 1, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                 llRegionSay(dChannel, "ShowHideLowerLegRight");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 1, <1.0, 1.0, 1.0>, 1.0]);
                 }
                 }
                 
            if (face == 4 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideUpperLegLeft");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 4, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideUpperLegLeft");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 4, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
          if (face == 5 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideUpperLegRight");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 5, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideUpperLegRight");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 5, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 2 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideThightLeft");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideThightLeft");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
        if (face == 3 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideThightRight");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideThightRight");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 6 && link == 16)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideTummy");
            llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 6, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideTummy");
                 llSetLinkPrimitiveParamsFast(16, [PRIM_COLOR, 6, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 4 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideChest");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 4, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideChest");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 4, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
        if (face == 2 && link == 14)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideLeftPeck");
            llSetLinkPrimitiveParamsFast(14, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideLeftPeck");
                 llSetLinkPrimitiveParamsFast(14, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 3 && link == 14)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideRightPeck");
            llSetLinkPrimitiveParamsFast(14, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideRightPeck");
                 llSetLinkPrimitiveParamsFast(14, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 5 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideNeck");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 5, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideNeck");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 5, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
                 if (face == 0 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideLowerArmLeft");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 0, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideLowerArmLeft");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 0, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
                         if (face == 1 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideLowerArmRight");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 1, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideLowerArmRight");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 1, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 2 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideUpperArmLeft");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideUpperArmLeft");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 2, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 3 && link == 15)
           
            
        {
            if(isOne)
            {
                llRegionSay(dChannel, "ShowHideUpperArmRight");
            llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 0.4]);
            }
            
             else
            {
                llRegionSay(dChannel, "ShowHideUpperArmRight");
                 llSetLinkPrimitiveParamsFast(15, [PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 1.0]);
                 }
        }
        
         if (face == 3 && link == 13)
           
            
        {
                llRegionSay(dChannel, "ShowHideALL");
                 llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
        }

                 
        }}
    
    
    }
integer dChannel;
integer lHandle;
key id;
list pattern = [0.0,0.05,0.1,0.15,0.20,0.25,0.3,0.25,0.20,0.15,0.10,0.05];
float interval = 0.15; 
integer prim = LINK_SET; 
integer face = ALL_SIDES; 
integer glow_index;
integer color_index;
integer counter;
integer isOn;
integer glowOn;


remove_listen_handle()
{
    llListenRemove(lHandle);

}

Pulse()
{
    glow_index = (glow_index + 1) % llGetListLength(pattern);
    llSetLinkPrimitiveParamsFast(prim,[PRIM_GLOW,face,llList2Float(pattern,glow_index)]);
}



default
{
    
    changed(integer change)
    {
        if(change & (CHANGED_OWNER | CHANGED_INVENTORY)) //note that it's & and not &&... it's bitwise!
        {
            llResetScript();
        }
    }
    
    on_rez(integer start_param)
    {
       llResetScript();
    }

    state_entry()
    {
         dChannel = 1;
        id = llDetectedKey(0);

        lHandle = llListen(dChannel, "", "", "");


    


}
    listen(integer channel, string name, key id, string message)
    {
        
                   list params = llGetLinkPrimitiveParams(1, [PRIM_DESC]);
           float para = llList2Float(params, glowOn);
        
        isOn = !isOn;



//WHITE---------------------------------------------------------------------
 if (message == "StarSetColorWhite")
        { 

                llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0]);
            }
            
//RED---------------------------------------------------------------------
     if (message == "StarSetColorRed")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.498>, 1.0]);
            }
            
//ORANGE---------------------------------------------------------------------

             if (message == "StarSetColorOrange")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.929, 0.635, 0.337>, 1.0]);
            }
            
//YELLOW---------------------------------------------------------------------
               if (message == "StarSetColorYellow")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.929, 0.929, 0.388>, 1.0]);
            }
            
//Green---------------------------------------------------------------------
               if (message == "StarSetColorGreen")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.365, 1.000, 0.365>, 1.0]);
            }
            
//Torqiose---------------------------------------------------------------------
               if (message == "StarSetColorTorquise")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.467, 0.929, 0.929>, 1.0]);
            }            
            
//Blue---------------------------------------------------------------------
               if (message == "StarSetColorBlue")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.192, 0.596, 1.000>, 1.0]);
            }       
            
//Purple---------------------------------------------------------------------
               if (message == "StarSetColorPurple")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.647, 0.294, 1.000>, 1.0]);
            }           
            
//Pink---------------------------------------------------------------------
               if (message == "StarSetColorPink")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.996, 0.325, 1.000>, 1.0]);
            }         
            
//Black---------------------------------------------------------------------
               if (message == "StarSetColorBlack")
     {
     
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_COLOR, ALL_SIDES, <0.0, 0.0, 0.000>, 1.0]);
            }         
            
//GLOW---------------------------------------------------------------------
               if (message == "GlitterGlow0")
     {
     llSetLinkPrimitiveParams(1,[PRIM_DESC, "0.0"]);
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_GLOW, ALL_SIDES, 0.0]);
            llSetTimerEvent(0.0);
            }         
            
              if (message == "GlitterGlow15")
     {
     llSetLinkPrimitiveParams(1, [PRIM_DESC, "0.15"]);
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_GLOW, ALL_SIDES, 0.15]);
                       llSetTimerEvent(0.0);
            }         
            
             if (message == "GlitterGlow30")
     {
     llSetLinkPrimitiveParams(1, [PRIM_DESC, "0.30"]);
      llSetLinkPrimitiveParamsFast(LINK_SET,[

            PRIM_GLOW, ALL_SIDES, 0.30]);
                       llSetTimerEvent(0.0);
            }       
            
             if (message == "GlitterGlowPulse")
     {
         llSetLinkPrimitiveParams(1, [PRIM_DESC, "0.0,0.05,0.1,0.15,0.20,0.25,0.3,0.25,0.20,0.15,0.10,0.05"]);
         llSetTimerEvent(interval);
Pulse();

            }       
            

           
        if (message == "ShowHideLowerLegLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 1.0, 0);
          
                llSetLinkPrimitiveParamsFast(2,[

            PRIM_GLOW, 0, 0.0]);

            }
           
            
            else
            {
                llSetLinkAlpha(2, 0.0, 0);
                
                
                 llSetLinkPrimitiveParamsFast(2,[

            PRIM_GLOW, 0, para]);

            }
                 
            }
            
             if (message == "ShowHideLowerLegRight")
        
        {
            if(isOn) 
            {
            llSetLinkAlpha(2, 0.0, 3);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 3);
            }
            }
            
             if (message == "ShowHideLowerLegLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 0.0, 0);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 0);
            }
            }
             if (message == "ShowHideUpperLegLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 0.0, 1);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 1);
            }
            }
            
             if (message == "ShowHideUpperLegRight")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 0.0, 4);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 4);
            }
            }
            
             if (message == "ShowHideThightLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 0.0, 2);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 2);
            }
            }
            
             if (message == "ShowHideThightRight")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(2, 0.0, 5);
            }
            
            else
            {
                llSetLinkAlpha(2, 1.0, 5);
            }
            }
            
             if (message == "ShowHideTummy")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(4, 0.0, 2);
            }
            
            else
            {
                llSetLinkAlpha(4, 1.0, 2);
            }
            }
            
            if (message == "ShowHideChest")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 7);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 7);
            }
            }
            
             if (message == "ShowHideLeftPeck")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 3);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 3);
            }
            }


            if (message == "ShowHideRightPeck")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 6);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 6);
            }
            }
            
            if (message == "ShowHideNeck")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 0);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 0);
            }
            }
            
            if (message == "ShowHideLowerArmLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 1);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 1);
            }
            }
            
             if (message == "ShowHideLowerArmRight")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 4);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 4);
            }
            }
            
            if (message == "ShowHideUpperArmLeft")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 2);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 2);
            }
            }
            
            if (message == "ShowHideUpperArmRight")
        
        {
            if(isOn)
            {
            llSetLinkAlpha(3, 0.0, 5);
            }
            
            else
            {
                llSetLinkAlpha(3, 1.0, 5);
            }
            }

            if (message == "ShowHideALL")
        
            {
            llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
            }
            

}


timer()
{

Pulse();
    }
}


 

Edited by arisaie
Link to comment
Share on other sites

Your scripts are very difficult to read because the indentation is inconsistent, along with the extra empty lines.

Many of your conditions could be simplified for easier editing and less errors, too.

To give you an idea, here's one way to reduce the amount of scrolling and formatting troubles for the first script. It's not perfect and has some bugs when it comes to the buttons (namely that it will hide non-specified faces too). But there is still more cleanup that could be done with lists which would get rid of almost all of the button code, while avoiding unused faces.

integer dChannel;
integer lHandle;
key id;
key AvatarKey;
integer isOne;

default
{
    changed(integer change)
    {
        if(change & CHANGED_OWNER) 
        {
            llResetScript();
        }
    }

    attach(key AvatarKey)
    {
        AvatarKey = llGetOwner();
        llRequestPermissions(AvatarKey, PERMISSION_ATTACH);
    }

    run_time_permissions(integer perm)
    {
        AvatarKey = llGetOwner();
        llRequestPermissions(AvatarKey, PERMISSION_ATTACH);
    }

    touch_start(integer num_detected)
    {
        //dChannel = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF);
        isOne = !isOne;
        dChannel = 1;
        integer link = llDetectedLinkNumber(0);
        integer face = llDetectedTouchFace(0);
        AvatarKey = llGetOwner();
        integer perm;

        if (face == TOUCH_INVALID_FACE)
        {
            llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
            return;
        }

        // store the original color
        list   colorParams   = llGetLinkPrimitiveParams(link, [PRIM_COLOR, face]);
        vector originalColor = llList2Vector(colorParams, 0);


        //WHITE---------------------------------------------------------------------
        if (face == 4 && link == 1)
        llRegionSay(dChannel, "StarSetColorWhite");


        //RED---------------------------------------------------------------------

        if (face == 3 && link == 1)
        llRegionSay(dChannel, "StarSetColorRed");

        //ORANGE---------------------------------------------------------------------

        if (face == 2 && link == 1)
        llRegionSay(dChannel, "StarSetColorOrange");  

        //YELLOW---------------------------------------------------------------------

        if (face == 5 && link == 1)
        llRegionSay(dChannel, "StarSetColorYellow");  

        //Green---------------------------------------------------------------------

        if (face == 0 && link == 1)
        llRegionSay(dChannel, "StarSetColorGreen");  

        //Torquise---------------------------------------------------------------------

        if (face == 4 && link == 2)
        llRegionSay(dChannel, "StarSetColorTorquise");  

        //Blue---------------------------------------------------------------------

        if (face == 1 && link == 2)
        llRegionSay(dChannel, "StarSetColorBlue");  

        //Purple---------------------------------------------------------------------

        if (face == 3 && link == 2)
        llRegionSay(dChannel, "StarSetColorPurple");  

        //Pink---------------------------------------------------------------------

        if (face == 2 && link == 2)
        llRegionSay(dChannel, "StarSetColorPink");  

        //Black---------------------------------------------------------------------

        if (face == 0 && link == 2)
        llRegionSay(dChannel, "StarSetColorBlack");  


        //---------------------------------------------------------------------
        //Glow---------------------------------------------------------------------


        if (face == 0 && link == 3)
        llRegionSay(dChannel, "GlitterGlow0");
        if (face == 1 && link == 3)
        llRegionSay(dChannel, "GlitterGlow15");
        if (face == 2 && link == 3)
        llRegionSay(dChannel, "GlitterGlow30");
        if (face == 3 && link == 3)
        llRegionSay(dChannel, "GlitterGlowPulse");


        //ALPHA---------------------------------------------------------------------

        float alpha = 1.0;
        if (isOne)
        {
            alpha = 0.4;
        }

        if (link == 16)
        {
            llSetLinkPrimitiveParamsFast(link, [PRIM_COLOR, face, <1.0, 1.0, 1.0>, alpha]);
            if (face == 0) llRegionSay(dChannel, "ShowHideLowerLegLeft");
            if (face == 1) llRegionSay(dChannel, "ShowHideLowerLegRight");
            if (face == 4) llRegionSay(dChannel, "ShowHideUpperLegLeft");
            if (face == 5) llRegionSay(dChannel, "ShowHideUpperLegRight");
            if (face == 2) llRegionSay(dChannel, "ShowHideThightLeft");
            if (face == 3) llRegionSay(dChannel, "ShowHideThightRight");
            if (face == 6) llRegionSay(dChannel, "ShowHideTummy");
        }

        if (link == 15)
        {
            llSetLinkPrimitiveParamsFast(link, [PRIM_COLOR, face, <1.0, 1.0, 1.0>, alpha]);
            if (face == 4) llRegionSay(dChannel, "ShowHideChest");
            if (face == 5) llRegionSay(dChannel, "ShowHideNeck");
            if (face == 0) llRegionSay(dChannel, "ShowHideLowerArmLeft");
            if (face == 1) llRegionSay(dChannel, "ShowHideLowerArmRight");
            if (face == 2) llRegionSay(dChannel, "ShowHideUpperArmLeft");
            if (face == 3) llRegionSay(dChannel, "ShowHideUpperArmRight");
        }

        if (link == 14)
        {
            llSetLinkPrimitiveParamsFast(link, [PRIM_COLOR, face, <1.0, 1.0, 1.0>, alpha]);
            if (face == 2) llRegionSay(dChannel, "ShowHideLeftPeck");
            if (face == 3) llRegionSay(dChannel, "ShowHideRightPeck");

        }

        if (link == 13)
        {
            if (face == 3)
            {
                llRegionSay(dChannel, "ShowHideALL");
                llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
            }
        }
    }
}

When it comes to your actual question about needing to click twice for a different face, that's because you have a single "switch" variable for the whole HUD. You would need to keep track of each button/face individually. Again, this can be done with lists. I would also recommend that you don't send a vague "ShowHidePart" message to the body, but instead only "ShowPart" or "HidePart". This would get rid of the need to keep track of toggling parts in the body as well.

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

2 hours ago, Wulfie Reanimator said:

You would need to keep track of each button/face individually. Again, this can be done with lists.

for less than 32 elements and only on/off, using a single integer as a bitfield would be more efficient, but the OP would probably be better off understanding how lists work.Testing the color/alpha of the touched face should in-theory also be a viable alternative. (N.B: scripts cannot examine some prim properties of objects that are no-mod to the current owner)

My inclination would be to try and embed a coma-separated value list into the description of each (touchable) linked prim, to avoid many of the if-then chains.

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

28 minutes ago, Quistess Alpha said:

for less than 32 elements and only on/off, using a single integer as a bitfield would be more efficient, but the OP would probably be better off understanding how lists work.

The list method is probably easier to maintain too (which is already a challenge). I think it's unlikely that a HUD like this would need to be concerned about being efficient.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 496 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...