Jump to content

Clothing Texture Changer Script/Hud help?


EvalynnFoxtrot
 Share

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

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

Recommended Posts

So... I've just recently figured out how to make rigged mesh in Secondlife, and I want to make a hud that comes with a shirt i've made that has the ability to change the tops texture (I have 14 different colors for the same mesh) and instead of 14 differently colored meshes I want to be able to just have the owner of the shirt click on a different color in the hud and then have the texture load onto the mesh top using the textures UUID. I have absolutely no idea how to script in LSL ... only Javascript and C# :matte-motes-crying: If anyone would be willing to help me I would greatly appreciate it.

Link to comment
Share on other sites

You may want to post instead in the "Wanted" forum to ask for a completed script. Or, because this is such a very common thing, you'll probably find what you need already for sale on Marketplace, and possibly in public domain script libraries.

This isn't to put you off trying it yourself, and folks here are eager to help if you try (but not so eager to start a script from scratch).

Link to comment
Share on other sites

First of all, a HUD is NO DIFFERENT to anything else so don't get hung up on the "It's a HUD" concept.

Basically, you'll have a script in the mesh object which will perform two main functions.  First is to listen for messages coming from the sending script.  The second function is to set textures.

For this you'll need to read the wiki http://wiki.secondlife.com/wiki/LSL_Portal for the following:-

llListen and the listen event

llSetTexture, llSetLinkPrimitiveParamsFast, llSetLinkTexture (depends on how you do this as to which you use, can't even remember if there's a llSetLinkTexture anymore, sometimes I make stuff up :) )

For the sending object, you can make this with several buttons (prims linked together), you detect which was touched and then send a UUID.

You'll need to read up on:-

llRegionSayTo (the destination key can be the key of the avatar, this way you don't broadcast on a listenable channel, it's a teensy bit more secure but still somewhat pointless since it's trivial to retrieve textures from cache anyway but then they're only suitable for that mesh item so it's a bit of a non drama anyway!).

llDetectedLinkNumber

Since you have skills in other languages, the rest of the process should come quickly.

 

 

 

 

  • Like 1
Link to comment
Share on other sites

I agree with everything Sassy said. But you might want to use llRegionSayTo instead of llRegionSay whenever possible. Not only is it more secure, it also prevents you from having problems with other scripts using the same channels (depending on how you're select the channels this may or may not matter) and not having to to check the listen-conditions for every other script in the region has an extremely small positive impact on the servers script-performance ;-)

Link to comment
Share on other sites

Okay, so I've basically gotten a script written out, but having an issue where no matter what button i click on the textures will start from the top UUID and cycle through all 14 textures then stop on the last one. heres my listening script attached to the shirt.

 state_entry()    {        listenHandle = llListen(-78640, "", NULL_KEY, "");            }     listen(integer channel, string name, key id, string message)    {        if(message = "DarkGreyZT")        {            llSetLinkTexture(LINK_SET, "df560c6a-66e1-af06-7fd0-f467fd8ee70c", ALL_SIDES);        }                if(message = "LavendarZT")        {            llSetLinkTexture(LINK_SET, "2e2b6b77-888b-bcf0-6f6a-b0cec4d35ec0", ALL_SIDES);        }    }}

and then heres part of the sending script,

default{       touch_start(integer num_detected)    {        key owner = llGetOwner();        llRegionSayTo(owner,-78640,"DarkGreyZT");    }}

any ideas on what might be causing the issue? :o

Link to comment
Share on other sites

Nothing in either of those scripts will cycle through textures at all.  Your sending script will always send only a message that says the message "DarkGreyZT", and your receiving script will apply the texture with UUID = "df560c6a-66e1-af06-7fd0-f467fd8ee70c" to all sides of every link in the receiving object. The receiving script only knows of two textures, so it can't cycle through 14 of them.   If you are seeing textures cycling, then you have another script doing it (possibly a script that you left in the object while you were testing?).

Now, if I were writing that receiving script, I would make the second if test into an else if, because there's no point in having the script do the test unless the first test has failed.  That won't affect the way the script responds in this simple case, but it's wasteful of time.  In a more complicated script, it could also lead to having the results of a later if test reverse the effects of an early one.

Link to comment
Share on other sites


Rolig Loon wrote:

... it could also lead to having the results of a later
if
test reverse the effects of an early one.

... especially when the "==" conditional operator  is mistakenly replaced with "=" assignment as in this case.

(None of which has anything to do with the reported misbehavior, which I agree must be due to some left-behind scripts somewhere, or parts of the sending script we're not seeing.)

Link to comment
Share on other sites

"The receiving script only knows of two textures, so it can't cycle through 14 of them." the Receiving script actuall has all the UUID's the reason for there only being two in the example i posted here was to shorten up the ammount of room that the code took up.

Anyways, Thanks for the help guys, It's behaving how it should now. :)

Link to comment
Share on other sites

  • 1 year later...

Looking back at the OP's posted work, I'm guessing that she fixed it by changing the "=" to "==" in her if (or else if) tests.  As written, those "=" choices will indeed all fail and leave nothing but the very last one, which presume will be

 

else{    //Rez the last item}

But only the OP knows for sure.  This thread is a year and a half old, though, so don't expect to hear.  ;)

Link to comment
Share on other sites

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