Attach from an attachment
|
|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
01-13-2007 15:57
I really don't get it!
I wear an attachment and I want this attachment to attach (or detach) from my AV another attachment.
I tought about scripting the second attachment to be attached on rez (and it works), then I rez it from the other's attachement script. And this doesn't work!
How could this be handled?
Thanks!
Rael
|
|
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
|
01-13-2007 18:15
Explicitly test for the attach permission in on_rez: if ( (llGetOwner() == llGetPermissionsKey()) && (llGetPermissions() & PERMISSION_ATTACH) ) llWhisper(0, "Proper permissions"); else llWhisper(0, "Don't have permission to attach, or agent mismatch"); Also, it seems that you can't attach something that's phantom so be sure to check for that as well. (It also won't work on parcels that have either no build, or no object entry set)
|
|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
01-14-2007 01:25
Thanks Kitty. Actually I can make the object attaching himself if I touch it so the permissions should be ok. Now I'd like to have it attached based on another event.
Imagine I have this object (say a flower) in the inventory of an object I'm wearing (say an hat). What I like to see is that when I touch the hat, the flower gets attached to my right hand. It would be ok if the flower had to be in my inventory rather than object's one..
Maybe is not possible at all?
Rael
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-14-2007 02:34
From: Rael Delcon Thanks Kitty. Actually I can make the object attaching himself if I touch it so the permissions should be ok. Now I'd like to have it attached based on another event.
Imagine I have this object (say a flower) in the inventory of an object I'm wearing (say an hat). What I like to see is that when I touch the hat, the flower gets attached to my right hand. It would be ok if the flower had to be in my inventory rather than object's one..
Maybe is not possible at all?
Rael You cannot attach an object from your inventory via script. In fact you cannot attach any object apart from the one the script is in, and then only if permissions have already been granted.
|
|
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
|
01-14-2007 06:00
From: Rael Delcon Imagine I have this object (say a flower) in the inventory of an object I'm wearing (say an hat). What I like to see is that when I touch the hat, the flower gets attached to my right hand. It would be ok if the flower had to be in my inventory rather than object's one. I only suggested adding that to make absolutely sure it's not due to permissions; if you put it in on_rez before you try to attach, then you know it's not the permissions and can look elsewhere. In your example, you would first attach the flower manually, which triggers the attach event in the script in which you request the attach permission for yourself. Detach the flower, then put it into the hat's inventory. The hat rezzes the flower somewhere close to the avie, triggering the flower's on_rez. In on_rez you attach the flower to the right hand. You didn't comment on whether the flower was phantom or not. It never worked for me trying to attach a phantom prim by script for some reason.
|
|
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
|
01-14-2007 06:10
Flower: default { state_entry() { } attach(key kAgentId) { if (kAgentId) llRequestPermissions(kAgentId, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION); }
run_time_permissions(integer nPermMask) { }
on_rez(integer nParam) { if ( (nParam) && (llGetPermissions() & PERMISSION_ATTACH) && (llGetPermissionsKey() == llGetOwner()) ) { llAttachToAvatar(ATTACH_RHAND); } } }Hat: default { state_entry() { } touch_start(integer cntTouch) { if (llDetectedKey(0) == llGetOwner()) llRezObject("Flower", llGetPos() - <0.0, 0.0, 1.0>, ZERO_VECTOR, ZERO_ROTATION, 1); } }I didn't test it but that should be close to the basic part you'd need  . Steps: 1) put the flower's script in the flower and wear it normally, that'll ensure it has attach permissions for you 2) put the flower in the hat (I'm assuming it's named "Flower"  3) put the hat's script in the hat 4) wear the hat and touch it and it should rez the flower and attach it to your right hand (Again, won't work on parcels that either disallow building or disallow object entry)
|
|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
01-14-2007 08:13
Thanks Kitty. It is exactly what I would have like to do (well I was hoping not to have to request permissions again but I understand lsl limitations Rael
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
01-14-2007 11:34
From: Newgate Ludd You cannot attach an object from your inventory via script. In fact you cannot attach any object apart from the one the script is in, and then only if permissions have already been granted. Not ENTIRELY true Newgate.. you could use an attachment, like a HUD.. to rez a second attachment, that would then use the onrez event to get permissions to attach. edit: looks above. Could you solve the "requesting permissions again" issue by wearing the item once, before placing it in the inventory of the rezzing prim? -- But as for getting an attachment to force another attachment to unwear.. you'd have to be able to modify the target attachment.. then simply have it listen for a specific command, and unwear itself. (sadly, there's no way to script "drop" 
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
|
01-14-2007 12:21
From: Winter Ventura Could you solve the "requesting permissions again" issue by wearing the item once, before placing it in the inventory of the rezzing prim? That's Step 1 in my post  . From: Rael Delcon It is exactly what I would have like to do (well I was hoping not to have to request permissions again but I understand lsl limitations I'm not entirely sure what you mean by having to request permissions again? llGetPermissions() doesn't ask for new permissions, it merely checks the existing permissions it currently holds. What you could do in a finished product is llOwnerSay("Please read the instructions and set up the flower before use."  ; if it doesn't have the permission to remind the user to skim through the documentation. The double check is there to make sure you can attach, and that you have attach permission for the current owner (in the case where you give the hat to someone else the new owner will have to first wear the flower manually and replace the old one that's in the hat's inventory).
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-14-2007 12:45
From: Winter Ventura Not ENTIRELY true Newgate.. you could use an attachment, like a HUD.. to rez a second attachment, that would then use the onrez event to get permissions to attach. edit: looks above. Could you solve the "requesting permissions again" issue by wearing the item once, before placing it in the inventory of the rezzing prim? -- But as for getting an attachment to force another attachment to unwear.. you'd have to be able to modify the target attachment.. then simply have it listen for a specific command, and unwear itself. (sadly, there's no way to script "drop"  I agreee Winter, my point was you cannot directly attach another item, it would need its own script.
|
|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
01-15-2007 00:50
Thanks everybody! I acutally missed point 1) from Kitty's answer now it works as I like it  Rael
|
|
Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
|
01-15-2007 02:50
One thing I've seen done is an attachment which rezzes another attachment, and then continues to check for the existence of attachment #2. If attachment #2 has been detached, another instance is rezzed in its place.
|