Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can you change attachment points?

Purrts Trumbo
Registered User
Join date: 7 Sep 2005
Posts: 22
01-16-2006 23:57
Usually, with a little searching, I've been able to answer anything I've come across. But, now I'm stumped. I'm trying to create a script that changes attachment points. It's drawing a sword from a back sheath. I've tried detaching and reattaching, but the object just returns to inventory. Same with putting the reattach in an attach state looking for a NULL_KEY to make sure it's not attached.

Here's what I've got.

CODE


default
{
state_entry()
{
integer perm = llGetPermissions();
if( !(perm & PERMISSION_TRIGGER_ANIMATION) || !(perm & PERMISSION_ATTACH) ) {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION|PERMISSION_ATTACH);
}
llListen(700,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message) {
if(message == "draw") {
if(llGetAttached() != ATTACH_RHAND ) {
llStartAnimation("DrawSword-Right-Grab");
llSleep(1.0);
llStopAnimation("DrawSword-Right-Grab");

llAttachToAvatar(ATTACH_RHAND);

llStartAnimation("DrawSword-Right");
} else {
llOwnerSay("Check your hand. You already have it.");
}
}
if(message == "sheath") {
llStopAnimation("DrawSword-Right");
}
}
}
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-17-2006 02:47
llAttachToAvatar is, I believe, intended only for objects lying around in-world. Not for object already attached, and certainly not for inventory items, unfortuanately.

The way most ppl seem to attack this problem is to have two sword attachments, one on the back and one in the hand. At any time, only one is visible, and the other is hidden but setting its alpha to 0.

Both swords listen for a command said in-between your two animations to toggle their visibility.
Purrts Trumbo
Registered User
Join date: 7 Sep 2005
Posts: 22
01-17-2006 07:40
Yeah, I thought of that after shutting down for the evening. It sounds like the only way to go. Since you can't bring something out if inventory via script. And, apparently, you can't change attachment points.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
01-17-2006 08:52
Thank you! I was trying to make my sword do something like this, and I got the animation to play but the sword never moved, and it never occurred to me that people were faking it...
Katherine Marat
Registered User
Join date: 14 Sep 2005
Posts: 3
01-17-2006 11:23
What if you had the shealth rez the sword and then pick its attach point.. would that work..?

It might look like its being propelled out of your back when it unshealths but thats kinda cool isnt it..?
Deneria Sholokhov
Leaf on the Wind
Join date: 25 Oct 2005
Posts: 12
01-17-2006 15:54
that would work, yes, however I have found that it is hard to make it look good, rezing things from attachment and attaching causes issues and usually does not look as good as an embedded anim and the invis model.

however, if you got the push just right....hmm, now I want to try this :)
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-18-2006 00:03
Kat and Den - If you're thinking of sword that leaps up out of its scabbard, spinning in the air, and the being drawn to the av's outstretched hand, I can only say 2 things:
  1. WOW!!!
  2. Pleeeeeze - let me know if you ever build one - I'll pay good money for that
Great ideas.
Deneria Sholokhov
Leaf on the Wind
Join date: 25 Oct 2005
Posts: 12
01-18-2006 11:46
that is exactly what I am thinking of, just need to find the time to figure it out in all my other projects.

Problem with this approach is the problem with ALL attachment approaches from objects created from attachements, it will soon clutter up your inventory with copies of the sword you draw. There is no way to remove and DELETE the attachment. As soon as you attach, a copy is put into your inventory and marked as worn, when you detach it, the object stays in inventory.

Most people would not mind at first, but I believe the novelty would wear off and the frustration of having so much crap in the inventory would win out.
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
01-18-2006 11:54
From: Deneria Sholokhov
that is exactly what I am thinking of, just need to find the time to figure it out in all my other projects.

Problem with this approach is the problem with ALL attachment approaches from objects created from attachements, it will soon clutter up your inventory with copies of the sword you draw. There is no way to remove and DELETE the attachment. As soon as you attach, a copy is put into your inventory and marked as worn, when you detach it, the object stays in inventory.

Most people would not mind at first, but I believe the novelty would wear off and the frustration of having so much crap in the inventory would win out.

Not only that, but an object in-world attempting to attach will pop up a dialog in the upper right corner asking if you want it to attach or not.
_____________________