Jump to content

ON/OFF HUD TO CHANGE TRANSPARENCY OF WORN OBJECTS


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

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

Recommended Posts

Hello:

 

Looking for some script help.

 

So here's what I would like to do.

 

I have a HUD with three buttons that will control the transparency of three different worn objects each comprised of a linked set of prime.

HUD Button ONE:  Makes OBJECT-1 opaque/visible and OBJECT-2 and OBJECT-3 TRANSPARENT

HUD Button TWO:  Makes OBJECT-2 opaque/visible and OBJECT-1 and OBJECT-3 TRANSPARENT

HUD Button THREE:  Makes OBJECT-3 opaque/visible and OBJECT-1 and OBJECT-2 TRANSPARENT

 

So the HUD script in each button is a simple channel chat script that activates the the script in the three worn linked set objects.

 

That part I'm pretty sure I can figure out.

 

Where I am challenged is the script to put in each worn linked set object.

 

I could make three scripts for each worn linked set object but thought it could also just be one script if I can get the listen channel for the HUD button chat to distinguish between the three sets.  I haven't been doing much scripting lately so I'n totes rusty on how to do this.

 

Can I have just one channel and have three different chat messages or do I need three separate channels - one for each chat message?

 

Do I replace string name with the name of the object?

 

I'm confused and probably making this far more complicated than it need be.

 

Not sure how to lay out the hierarchy.

 

//HUD BUTTON ONE

integer channel=12345

 

//HUD BUTTON TWO

integer channel=12346

 

//HUD BUTTON THREE

integer channel=12347

 

default

{

//HUD BUTTON ONE - OBJECT-1

listen(integer channel, string name, key id, string message){    if (message == "ONE“)

{llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);}

//HUD BUTTON ONE - OBJECT-2

listen(integer channel, string name, key id, string message){    if (message == "ONE“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

  //HUD BUTTON ONE - OBJECT-3

listen(integer channel, string name, key id, string message){    if (message == "ONE“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

}

else

//HUD BUTTON TWO - OBJECT-1

listen(integer channel, string name, key id, string message){    if (message == "TWO“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

//HUD BUTTON ONE - OBJECT-2

listen(integer channel, string name, key id, string message){    if (message == "TWO“)

{llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);}

  //HUD BUTTON ONE - OBJECT-3

listen(integer channel, string name, key id, string message){    if (message == "TWO“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

}

else

//HUD BUTTON THREE - OBJECT-1

listen(integer channel, string name, key id, string message){    if (message == "THREE“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

//HUD BUTTON THREE - OBJECT-2

listen(integer channel, string name, key id, string message){    if (message == "THREE“)

{llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);}

  //HUD BUTTON THREE - OBJECT-3

listen(integer channel, string name, key id, string message){    if (message == "THREE“)

{llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);}

}

 

 

Thank you!

Link to post
Share on other sites

There are many ways to approach this challenge.  I often simply append (or prepend) a flag to each message, identifying who it's intended for.  So, for example, if I am sending a message that is meant to turn on Object A, I might send a message that says

llRegionSayTo(llGetOwner(), my_secret_channel, "A~ON");

Then, because Objects A, B, and C are all attached to me, my message will be sent to all of them.  Each object will then receive 

"A~ON"

and then ask:

list temp = llParseString2List( message, ["~"],[] );
if (  llList2String(temp,0) == llGetObjectName() )
{
    string command = llList2String(temp,1);
    if ( command == "ON")
    {
        //turn on
    }
    else
    {
        // turn off
    }
}

Assuming that Object A is named "A", it's the only attachment that will accept the message and act on it. 

Edited by Rolig Loon
typos. as always.
Link to post
Share on other sites

adding on here.  Probably i would go with a 3 switches array as the message

press button1 > string switches = "1~0~0"
press button2 > string switches = "0~1~0"
press button3 > string switches = "0~0~1"

"1" meaning show the linkset prim. "0" meaning hide the linkset prim. "~" is separator

then use Rolig's method to address the linkset object, substituting 'secret' in place of objectname for objects distributed with Modify permissions. Example:

// in HUD

string secret = "MyThing#16";

string message = secret + "~" + switches;
sendmessage(..., message);


//in Object

string secret = "MyThing#16";

listen(..., message)
{
   list params = llParseString2List(message, ["~"], []);
   if (llList2String(params, 0) == secret)
   {
      // here the switches are in params elements [1, 2, 3]
      for (i = 1; i <= 3; i++)
      {
          llSetLinkAlpha(i, llList2Float(params, i), ALL_SIDES);
      }
   }
}

 

Link to post
Share on other sites
  • 3 weeks later...
You are about to reply to a thread that has been inactive for 583 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...