Jump to content

Adding Texture to multiple Links and/or Faces


Cosmeja
 Share

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

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

Recommended Posts

Hello,

since some years I use a simple Texturechanger script for the HUDs of my Creations.

It looks like this:

---------------------------------------------------------------------------------------------------------------------------

integer channel = 9000049; // Channel for comms (Must be same as reciever).

string texture = "4f2abcfc-5df9-43b8-4fc1-ee30e8c96c01"; // UUID of Texture to apply
string normal = "072f449b-8098-1cc8-42f0-acc72c45ae70"; // UUID of NORMAL Texture to apply
string spec = "3eee90c2-497c-c4d8-a071-be01d402aa62"; // UUID of Specualr Texture to apply

integer link = LINK_SET;  // Link number to apply the texture to (LINK_SET for all links).
integer face = ALL_SIDES;  // Face number to apply the texture to (ALL_SIDES for all faces).
integer glossiness = 100; // Value of glosiness
integer environment = 0; // Value of environmental reflection

string SR = "*"; // Seperator to use in the list, must be the same
// as the seperator to be used within the reviever
// script.

////////////////////////////////////////////////////////////////////

default
{
    touch_start(integer total_number) // When object is touched.
    {
        // Say each texture property with the seperator inbetween so the reciever can parse it.
        //llRegionSay(channel,texture+SR+(string)link+SR+(string)face+SR+"SPECULAR"+SR+"NORMAL");
        llSay(channel,texture+SR+(string)link+SR+(string)face+SR+normal+SR+spec+SR+(string)glossiness+SR+(string)environment);
    }
}

--------------------------------------------------------------------------------------------------------------------------------------------

Now, I know I place the Number of a link or face here:

integer link = 1;
integer face = 2; 

which allowes me to adress ONE specific Link or Face.

But I would like to adress more then just one face or link, like:

integer link = 1 and 2 and 3;

:)

Is there a way to do it within this script?

Link to comment
Share on other sites

If the link combinations you want do not fit into one of the LINK_* constants, you would have to pass some type of list (I would suggest "Comma-separated values"). 

Then have the "receiving" script for your llSay() command interpret that list, and send the commands for each link in the llSetLinkPrimitiveParamsFast() command (or whichever command you use).  (You can send multiple links in one call.)

The only LINK_* constants are:

LINK_THIS

LINK_ROOT

LINK_SET

LINK_ALL_OTHERS

LINK_CHILDREN

They are all listed in any of the individual LINK_* constant wiki pages: https://wiki.secondlife.com/wiki/LINK_ALL_CHILDREN

Link to comment
Share on other sites

Your HUD script is basically constructing a custom message to send to the receiver. So sure, you could alter it to include additional link and face numbers in a single message. However, in doing that you would need to similarly alter the receiver script to understand the new message format and parse out the multiple link/face values from the single message.

Alternatively, you might be able to just send extra messages for each link and/or face depending on the situation. That would probably work without needing to modify the receiver, providing you maintain the same format.

As an aside, you can't define multiple discrete values into a single integer variable. Well... I mean you could encode multiple values into the integer (deep down it's just 32bits of data) but I imagine that's overkill for an application like this. The typical approach would be to use a list or some other kind of delineated string.

 

Generally speaking, when you have a function that takes a link number as an input parameter, you are limited to either the specific individual link or a handful of special LINK_* constants that can define certain links or a limited range (self, root, the entire linkset, everyone else, or all child links). For faces, it's even more limited: you can only specify the single target face or ALL_SIDES.

In order to target an arbitrary subset of link numbers (that aren't covered by the LINK_* constants) at the same time, you would need to use PRIM_LINK_TARGET. That signals that all the parameters that follow will apply to whatever link you specified there. You can have multiple PRIM_LINK_TARGET instances in the same parameter list to target other links in this manner.

  • Like 1
Link to comment
Share on other sites

1 minute ago, Fenix Eldritch said:

Alternatively, you might be able to just send extra messages for each link and/or face depending on the situation. That would probably work without needing to modify the receiver, providing you maintain the same format.

I like this solution, it is what I did in my own systems.  One message per link, that way I just add another message if needed for more links, potentially with different textures.

Link to comment
Share on other sites

17 minutes ago, Fenix Eldritch said:

Alternatively, you might be able to just send extra messages for each link and/or face depending on the situation. That would probably work without needing to modify the receiver, providing you maintain the same format.

That is what I am doing right now. Having a number of the SEND script in a button, each adressing the specific Link or Face.

I end up having up to four or more scripts in a button.

I thought by adressing multiple Links and/or faces within ONE script, it reduces not only the number of scripts in a button, but also the amount of work adding the texture UUID to each script.

I gues I will just go along the road of having multiple Scripts in my Buttons, since I have no clue of scripting beside knowing where to put my UUIDs or change Link/Face number etc :D

Thank you guys for your replys :)

Link to comment
Share on other sites

Oh I got it without needing to change the receiver script. I dont know if you ment this solution by saying

44 minutes ago, Fenix Eldritch said:

Alternatively, you might be able to just send extra messages for each link and/or face depending on the situation. That would probably work without needing to modify the receiver, providing you maintain the same format.

The Script now looks like this and can be alterd in the way (numbers of links or/and faces I need.

-------------------------------------------------------------------------------------------------------------------------------------------------------

i

integer channel = 1000049; // Channel for comms (Must be same as reciever).

string texture = "4f2abcfc-5df9-43b8-4fc1-ee30e8c96c01"; // UUID of Texture to apply
string normal = "072f449b-8098-1cc8-42f0-acc72c45ae70"; // UUID of NORMAL Texture to apply
string spec = "3eee90c2-497c-c4d8-a071-be01d402aa62"; // UUID of Specualr Texture to apply

integer link1 = 1;  // Link number to apply the texture to (LINK_SET for all links).
integer link2 = 2; // Face number to apply the texture to (ALL_SIDES for all faces).
integer face1 = 1;  // Link number to apply the texture to (LINK_SET for all links).
integer face2 = 2; // Face number to apply the texture to (ALL_SIDES for all faces).
integer glossiness = 100; // Value of glosiness
integer environment = 0; // Value of environmental reflection

string SR = "*"; // Seperator to use in the list, must be the same
// as the seperator to be used within the reviever
// script.

////////////////////////////////////////////////////////////////////

default
{
    touch_start(integer total_number) // When object is touched.
    {
        // Say each texture property with the seperator inbetween so the reciever can parse it.
        //llRegionSay(channel,texture+SR+(string)link+SR+(string)face+SR+"SPECULAR"+SR+"NORMAL");
        llSay(channel,texture+SR+(string)link1+SR+(string)face1+SR+normal+SR+spec+SR+(string)glossiness+SR+(string)environment);
        llSay(channel,texture+SR+(string)link2+SR+(string)face2+SR+normal+SR+spec+SR+(string)glossiness+SR+(string)environment);
    }
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Link to comment
Share on other sites

19 minutes ago, Cosmeja said:

That is what I am doing right now. Having a number of the SEND script in a button, each adressing the specific Link or Face.

That is... less than optimal. You can (and should) combine all of those into one script per button. Heck, you honestly can (and in my opinion really should) combine everything into a single HUD script. It isn't as daunting as you may think.

6 minutes ago, Cosmeja said:

The Script now looks like this and can be alterd in the way (numbers of links or/and faces I need.

Yes, that is precisely what I was going to say. You can simply add a new set of variables for additional links/faces/whatever and reference them in the new messages following the original. That is a better way than essentially duplicating the script for each message.

Going a few steps further, you can further combine everything into one script in the HUD root. For example, suppose you name the buttons on your HUD to something like "Button1", "Button2, "Button3"... and so on. Then you could but a script like this in the root and it would react to whatever button was clicked (providing the name matched) :

default
{
    touch_start(integer total_number)
    {
        string buttonName = llGetLinkName(llDetectedLinkNumber(0));
        
        llOwnerSay("user clcikd on "+buttonName); //debug readout
        
        if(buttonName == "Button1")
        {
            //do stuff for button1
            //you can put you messages for button1 here
        }
        else if(buttonName == "Button2")
        {
            //do stuff for button2
            //you can put you messages for button2 here
        }
        else if(buttonName == "Button3")
        {
            //do stuff for button3
            //you can put you messages for button2 here
        }
    }
}

You could then take those llSay commands you have in each button and instead copy them to the appropriate sections in this script instead. Make sure you also define all the needed variables as well.

 

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 513 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...