Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attaching a Prim to the Avatar

Strollerweb Market
Registered User
Join date: 20 Nov 2006
Posts: 21
01-18-2007 14:26
I'm looking for a way to a attache a Prim to my Avatar when a certan condition is meet! like take off a hat and have it attache to your left hand when you sit down, any ideas.
Hannah Shenley
Registered User
Join date: 25 Oct 2006
Posts: 21
01-18-2007 15:14
use 2 hats? 1 on your hand the other on your head. using some custom animation jiggery pokery, have 1 become invisible then the other visible. move hand, then swap back?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-18-2007 15:15
You can determine your current animation by using llGetAnimation(llGetOwner());

http://www.lslwiki.com/lslwiki/wakka.php?wakka=llGetAnimation

So, for example: if (llGetAnimation(llGetOwner()) == "Sitting";) ...would indicate that you are sitting down.

Most apparent attachment manipulation is a fake. Try Crtl-Alt-T while in world and eventually you'll see something like someone holding a pair of invisible guns in their hands while a visible pair show in holsters on their hips. A script in each gun can toggle the visibility between holster and hands giving the effect that the guns have been drawn.

http://www.lslwiki.com/lslwiki/wakka.php?wakka=llSetAlpha

Putting these ideas together I hope you can see how it would be possible have it appear that the postion of a hat changes when you sit down. With a lot of cunning (using a custom animation) it might be possible to have the hand rise to your head, switch the attachment visibility, and then let the hand return to your side. I suspect getting this to look smooth would be a challenge. :D
Siria Wilder
Registered User
Join date: 19 Jan 2007
Posts: 15
01-19-2007 05:07
This fake assumes you have enough free attachment spots to do so. But in many situation you desire the other way, switching an object at the same spot. Just like changing your weapon, switching an undershirt with a tattoo or simply changing your outfit on a button click. The fake is useless for cases like this, where real attaching/detaching is needed.

Any ideas how to make this possible?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-19-2007 06:25
From: Siria Wilder
This fake assumes you have enough free attachment spots to do so. But in many situation you desire the other way, switching an object at the same spot. Just like changing your weapon, switching an undershirt with a tattoo or simply changing your outfit on a button click. The fake is useless for cases like this, where real attaching/detaching is needed.

Any ideas how to make this possible?


short of rewriting SL?
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
01-19-2007 06:55
The best way to go is using two attachments and switching alpha between them. As mentioned earlier.

There is another way, but it's very convoluted and doesn't really add anything. But it will take up only the one attachment spot at a time.

Let's assume we're dealing with a head:
- Attach the object to head.

On moment of switch:
1. Rez a second hat from hat's inventory in front of the owner using llRezObject (requires the wearer rezzing rights on the plot though)
2. Give the original hat in inventory in the 'hat on head' to the newly rezzed hat (use llGiveInventory)
3. Have a separate script in this object request attaching to hand (using llAttachToAvatar); wearer needs to allow permission for this (requester).
4. After attaching succeeds, send a message using llSay to the 'hat on head'.
5. Detach the 'hat on head' using llDetachfromAvatar


Use the same process to change the hat back to the head.

As mentioned earlier there are no advantages to this method, except for only using one attachment point at a time. The disadvantages are:
- only works on plots where wearer can rez objects.
- much more scripting involved
- objects need to be copyable inside the main object. (so only commercial application is copy/no-transfer)
- requires the wearer to click on a permissions requester on every change.
- much higher server load
- takes a lot longer to process all steps

EDIT: On a side note, be very careful with objects that rez other objects then give 'themselves' to these objects. If this isn't handled carefully you'll have created something called a 'grey goo' attack object, and it's a good straight way to permabanning your account... ;)
_____________________
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-19-2007 09:00
From: Siria Wilder
This fake assumes you have enough free attachment spots to do so. But in many situation you desire the other way, switching an object at the same spot. Just like changing your weapon, switching an undershirt with a tattoo or simply changing your outfit on a button click. The fake is useless for cases like this, where real attaching/detaching is needed.

Any ideas how to make this possible?
One of the most popular shape changing attachments in SL uses a single attachment point. :p They commonly use the exact same technique to change appearance. You can toggle the invisibility of selected prims in an object and therefore have many 'shapes' hidden in the same attached object.
Strollerweb Market
Registered User
Join date: 20 Nov 2006
Posts: 21
01-21-2007 23:53
From: Siria Wilder
This fake assumes you have enough free attachment spots to do so. But in many situation you desire the other way, switching an object at the same spot. Just like changing your weapon, switching an undershirt with a tattoo or simply changing your outfit on a button click. The fake is useless for cases like this, where real attaching/detaching is needed.

Any ideas how to make this possible?


I got around this problem with Two hat's being in the Left hand at the same time by attaching one to the Left Forearm and repostioning it to look like it was in the left hand!

Then using:
llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES); //sets all attached prims Visable for one hat
llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); //sets all atached prims invisable for the other
With an 'If and else' statement in both hats that toggles the two statements.

Thank's to everyone in this thread for pointing me in the right direction :)