Jump to content

[SOLVED] HUD attaching clothes from owner's inventory


Couvaloure Rascon
 Share

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

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

Recommended Posts

Hey everyone,

So I've been working on my first HUD to try make my life easier (which it's what coding is for, isn't it?). I've figured out how to do it in a single prime, comparing the vectore where the click was done to every pairs of vector of each buttons (upper-left & lower-right). But when I try to give it its main function, now I get clueless.

I have a lot of pieces of clothes in my inventory, which are no-transfert and no-mod, and I would like to be able to wear them when I click on whatever buttons. I've saw a lot of things for attachements being located in the object's inventory, where the script is in the same inventory. But as you may guess, those are two different variables : they aren't attachements, so I can't Rez them, and they can't be in the inventory because of the permissions.

In conclusion, my questions are : is there are way to do it and, if yes, how? Either it is a magical permissions set that will let me place the clothes in my HUD's inventory, a series of LSL functions that will let me do that, etc.

Thank you for taking the time to read this and for any answers! :cathappy:

Link to comment
Share on other sites

You can use llAttachToAvatar or llAttachToAvatarTemp if you are attaching an item that is in the inventory of the scripted object, but there's no way that you can attach something from your own inventory with standard LSL.  You'll have to drag/drop the clothing items into your HUD and then attach from there.  Since you own the clothing and the HUD, there shouldn't be any problem with permissions.  You are not copying or transfering anything.

Link to comment
Share on other sites

So... since you said that it should be possible to transfert the items in the HUD, I tried back. And it worked. For reasons out of my understanding as I remember clearly trying this already and it wasn't doing anything.

Well thank you a lot! I now don't feel anymore like all that time working on the whole thing was wasted. I'll continue to work with what I've found yet, like llAttachToAvatar, as you mentioned.

 

But since we're here... could I also ask for a slightly related question? As said, I coded everything for the button finding, since I couldn't find any existing code for the one-prim HUDs. Would it be too much to ask for a light review, as I feel that it can get out of hand quickly. Right now, I only have two buttons, so it's nice, but as I'll be adding more, it will takes longer to find what was clicked.

 

vector _BoutonAll1 = <-0.00500, -0.87575, -0.19439>;vector _BoutonAll2 = <-0.00500, -0.92084, -0.20942>;vector _BoutonOpen1 = <-0.00500, -0.72645, -0.10321>;vector _BoutonOpen2 = <-0.00500, -0.92685, -0.15431>;list _Boutons = [_BoutonAll1, _BoutonAll2, _BoutonOpen1, _BoutonOpen2];integer _ListLength;integer CheckWhichButton(vector pos, integer boutonListPosition){    if(boutonListPosition >= _ListLength)        return -1;            vector positionTop = llList2Vector(_Boutons, boutonListPosition);    vector positionBottom = llList2Vector(_Boutons, boutonListPosition + 1);        if(pos.y <= positionTop.y && pos.y >= positionBottom.y)    {        if(pos.z <= positionTop.z && pos.z >= positionBottom.z)            return boutonListPosition / 2;    }        return CheckWhichButton(pos, boutonListPosition + 2);}

CheckWhichButton is called as the HUD is touched, with the integer 0. It then calls itself until it finds the appropriate button or until it reaches out of buttons to check. I'm sure there would be a way to make that less CPU asking. Any advices you could share with me please?

 

Link to comment
Share on other sites

The easiest way to make a multi-button surface -- whether it's a HUD or some other object -- is to use the llDetectedTouch* functions.  I usually prefer llDetectedTouchST, which checks for positions relative to the dimensions of the face, but it can be convenient sometimes to use llDetectedTouchUV, which checks positions relative to the dimensions of the texture on the face.  So, for example, if you had four HUD buttons and used the entire surface of the HUD, you could write something like this, which divides the surface into four equal sub-areas........

 

touch_start(integer num){    vector Where = llDetectedTouchST(0);    if (Where.x < 0.5)  // These are the buttons for Function #1    {        if (Where.y < 0.5)        {            // User pushed the lower left button  (= OFF, maybe?)        }        else        {            // User pushed the upper left button (= ON, maybe?)        }    }    else  // These are the button for function #2    {        if (Where.y < 0.5)        {            // User pushed the lower right button  (= OFF, maybe?)        }        else        {            // User pushed the upper right button (= ON, maybe?)        }    }} 

 

 There's no need for writing a user-defined function for something as simple as this.        

Link to comment
Share on other sites


Rolig Loon wrote:

You can use
llAttachToAvatar
or
llAttachToAvatarTemp
if you are attaching an item that is in the inventory of the scripted object...

Just for completeness, these functions don't work for items in the inventory of the scripted object, but rather the script calling these functions must be in the object to be attached, and that object must itself come to be rezzed on land where its scripts are permitted to run. (This related to another current thread about Mesh objects not registering as temp-on-rez for purposes of Land Impact.)

Link to comment
Share on other sites

So... in clear, relatively to my project, it means that it's plain impossible to do with no-mod objects? And same goes for clothings (like shirts, pants, etc.), which can't be Rez? Well that's anticlimactic. :matte-motes-confused:

Well thank you everyone for your answers. Even though that I won't be able to do what I wanted - should I maintain hopes for a possible update to be able to do it? - I'll know how to do when it will comes to rezzable objects (and to get where the user clicked on the hud!). Same goes for everyone whom comes across this discussion.

 

Have a nice day!

Link to comment
Share on other sites

Not speaking for the OP, but I can imagine two limitations here. The first being system clothes -- which aren't really "attached" at all, so yeah, they don't get rezzed -- but I think they, as well as actual attachments, are subject to the RLV mechanism that Prof suggests, and which may best fit this application.

The "no mod" thing I would guess applies to items that are no-mod to the person trying to set this up, and thus cannot have scripts inserted to perform the llAttachToAvatar /- Temp function.

I don't know anything useful about the prospects to enhance any of this. Other than RLV, I'd guess scripted application of system clothing layers to be a dead letter, but that's just a guess. Meanwhile, there's some recent interest in a feature request for attaching objects directly from a scripted object's inventory but I can't even guess whether it would ever be worked, or if so, when.

Link to comment
Share on other sites

Yes, I can see both of those limitations, but I think both come down to some semantic confusion.  If the OP is really talking about system clothing, which is "painted" on the av body, then there's no point in using the words "rez" or "attach" at all.  They don't apply.  You can't "rez" or "attach" a texture, which is what system clothing is.  If that's what the OP has been talking about, it's a waste of time.

The no-mod limitation will indeed make it impossible to add a script to the OP's clothing, so that will make any form of llAttachToAvatar unworkable.  I don't think we've gotten that far in the discussion, though. The OP's claim is that she can't rez the clothing because it's no-mod, which makes no sense to me.  If the clothing is no-mod, there isn't any point in trying to script it, but that has nothing to do with whether she can rez it.

Link to comment
Share on other sites

  • 2 weeks later...

Alright, I'll bring back this post alive, but only to say that everything worked.

First of all, sorry for the huge delay. I couldn't answer earlier because of some medical issues... anyway!

 

There might have been some confusions, from the starting point. I did meant non-primes clothes, like shirt, pants, etc. I knew that one couldn't Rez those, thus leading in my precocious disapointment, since Rolig seemed to say that it was the only way to have an object "attached" to an AV.

I then studied better Prof's suggestion, with RLV... and after a lot of fiddling (mainly figuring out how it all worked), I succeeded at making it work and attaching a shirt to my AV. In the case someone, in the futur, find this post while having the same intentions : llShout(-1812221819, "0,"+(string)llGetOwner()+",@attachall:Folder1/Folder2/.../FolderN=force") is what worked for me, while having that path in the #RLV folder. More information on the Wiki.

 

So thank you everyone for helping! It was quite appreciated. :3

 

PS: "OP" is, in this case, masculine~

Link to comment
Share on other sites

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